Author Topic: Wrap window procedure  (Read 6460 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Re: Wrap window procedure
« Reply #15 on: July 24, 2012, 10:44:23 AM »

The diifference between Sub and Function has almost disappeared. It just depends whether you are returning some some value.

Aurel

  • Guest
Re: Wrap window procedure
« Reply #16 on: August 08, 2012, 10:25:42 PM »
Hi Charles..
In my search i found this on FB forum:
Code: [Select]
DIM Shared AS WNDCLASSEX wcx
'DIM SHARED AS MSG wMsg
SUB SETUPWNDCLASS
  With wcx
    .cbSize=SizeOf( WNDCLASSEX )
    .style=CS_HREDRAW OR CS_VREDRAW OR CS_BYTEALIGNWINDOW
    .lpfnWndProc=Cast(WNDPROC,@WindowProc)
    .cbClsExtra=NULL
    .cbWndExtra=NULL
    .hInstance=GetModuleHandle(NULL)
    .hIcon=LoadIcon(null,IDI_APPLICATION)
    .hCursor=LoadCursor(NULL,IDC_ARROW)
'  .hbrBackground=cast( HBRUSH,COLOR_WINDOW + 1 )
    .hbrBackground=GetSysColorBrush(COLOR_BTNFACE)
    .lpszMenuName=NULL
    .lpszClassName=@"zWindow"
    .hIconSm=0
  End With
  RegisterClassEx(@wcx)
End Sub

My question is how cast pointer like this in Oxygen:
.lpfnWndProc=Cast(WNDPROC,@WindowProc)
What is the option?

Charles Pegge

  • Guest
Re: Wrap window procedure
« Reply #17 on: August 09, 2012, 02:38:30 AM »
No cast needed:

.lpfnWndProc=@WindowProc

Aurel

  • Guest
Re: Wrap window procedure
« Reply #18 on: October 27, 2012, 02:03:40 PM »
One guy (member of FB forum ) finaly explain to me how create multiple
windows and use one Window procedure.
I hope that i can translate this example to Oxygen. ::)

Aurel

  • Guest
Re: Wrap window procedure
« Reply #19 on: October 29, 2012, 01:02:44 PM »
Heh..it is easier then i think... ::)
I just changed CloseWindow() to reset window hendler to NULL :
Code: [Select]
Function CloseWindow(wnd as INT) as INT
DestroyWindow wnd
Return wnd=0
End Function

Sub EndProgram
PostQuitMessage 0
End Sub

As you see subroutine EndProgram just send PostQuitMessage(0)

Code: [Select]
'skeleton awin header
#include "awin2.inc" 
#lookahead ' for procedures
INT win,win2
INT msg
INT x,y,w,h,style
style=WS_MINMAXSIZE
INT button1,b1ID=100


win = SetWindow ("Window 1",40,40,400,300,0,style,&Main)
button1 = SetButton(win,4,4,80,24,"Click Me!",0x50000000,0x200,b1ID)
win2= SetWindow ("Window 2",460,40,400,300,0,style,&Main)

'msg loop
Wait()

'-------------------------------------------------------
FUNCTION Main(hwnd ,msg ,wparam ,lparam) As sys Callback

SELECT hwnd
'----------------------------------
CASE win
'.................................
Select msg

Case WM_CLOSE
CloseWindow(win)
print "win-1: " + str(win)
EndProgram  'send postQuitMessage(0)

End Select
'---------------------------------
CASE win2
'.................................
Select msg

Case WM_CLOSE
CloseWindow(win2)
print "win-2: " + str(win2)

End select

END SELECT

RETURN Default

END FUNCTION
'----------------------------------------------------------