WM_SIZE GPF's

Just starting out? Need help? Post your questions and find answers here.
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

WM_SIZE GPF's

Post by Edwin Knoppert »

This goes wrong, status bar not initialized or so..
See WM_SIZE message.
Enable the update...

Code: Select all

;=========================================================

; PBDev - PureBasic Developer, 1.011, 2003-04-27, 12:30

;=========================================================



#PBD_EXE = 1









#FORM1 = "FORM1"

#ID_FORM1_TOOLBAR1 = 100

#ID_FORM1_STATUSBAR1 = 101



#IDM_FORM1_MENU_6755444 = 1000





Declare.l Form1_Callback( WindowID, Message, wParam, lParam )

Declare.l PBD_CreateForm( sFormName.s, pCallBack.l )

Declare.l PBD_Main()





PBD_Main()

End





Procedure.l Form1_Callback( WindowID, Message, wParam, lParam )



    Protected nResult.l

    nResult = #PB_ProcessPureBasicEvents



    Select Message

    Case #WM_SIZE



;>>>> problemmaker..



        ;UpdateStatusBar( #ID_FORM1_STATUSBAR1 )



    Default



        ProcedureReturn nResult



    EndSelect





EndProcedure





Procedure.l PBD_Main()



    Protected Quit.l        ; End of form indicator

    Protected EventID.l     ; Message type

    Protected WindowID.l    ; hWnd



    ; The first form you want to show, evt. with callback

    WindowID = PBD_CreateForm( #FORM1, @Form1_Callback() )

    If WindowID



        ; Toolbar settings

        ToolBarStandardButton( 1, #PB_ToolBarIcon_New )

        ToolBarStandardButton( 2, #PB_ToolBarIcon_Open ) 

        ToolBarStandardButton( 3, #PB_ToolBarIcon_Save ) 

        ToolBarStandardButton( 4, #PB_ToolBarIcon_Print ) 

        ToolBarStandardButton( 5, #PB_ToolBarIcon_Find ) 

        ToolBarStandardButton( 6, #PB_ToolBarIcon_Replace )

        ToolBarSeparator() 

        ToolBarStandardButton( 7, #PB_ToolBarIcon_Cut ) 

        ToolBarStandardButton( 8, #PB_ToolBarIcon_Copy ) 

        ToolBarStandardButton( 9, #PB_ToolBarIcon_Paste ) 

        ToolBarStandardButton( 10, #PB_ToolBarIcon_Undo ) 

        ToolBarStandardButton( 11, #PB_ToolBarIcon_Redo )

        ToolBarSeparator() 

        ToolBarStandardButton( 12, #PB_ToolBarIcon_Delete )

        ToolBarStandardButton( 13, #PB_ToolBarIcon_Properties )

        ToolBarStandardButton( 14, #PB_ToolBarIcon_Help )

        

        ; Statusbar settings

        AddStatusBarField( 100 )

        StatusBarText( #ID_FORM1_STATUSBAR1, 0, "Field1" )

        AddStatusBarField( 32768 )

        StatusBarText( #ID_FORM1_STATUSBAR1, 1, "Field2" )



        ; Messageloop

        Repeat



            EventID = WaitWindowEvent()



            ; Message

            Select EventID

            Case #PB_EventMenu



                MessageRequester( "Information", "ToolBar or Menu ID: " + Str( EventMenuID() ), 0 )



            Case #PB_Event_CloseWindow

                Quit = 1

            EndSelect



        Until Quit = 1



    Else

        ProcedureReturn = 1

    EndIf



EndProcedure











Procedure.l PBD_CreateForm( sFormName.s, pCallBack.l )



    Protected hWnd.l

    sFormName = Trim( UCase( sFormName ) )



    Select sFormName

    Case #FORM1



        hWnd = OpenWindow( 0, 264, 209, 490, 232, #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_SizeGadget | #PB_Window_ScreenCentered, "Form1" )

        If hWnd



            If pCallBack

                SetWindowCallback( pCallBack )

            EndIf

            If CreateMenu( 0, hWnd )

                MenuTitle( "Menu 1" )

                    MenuItem( 1000, "Menu 1" )



            EndIf

            If CreateGadgetList( hWnd )



                CreateToolBar( 100, hWnd )
                CreateStatusBar( 101, hWnd )



            EndIf



        EndIf

EndSelect

ProcedureReturn hWnd

EndProcedure

Strange looking html changed by Berikco
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

(The preview worked fine, the resulting post doesn't)
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

I already know what happens.
The menu results in a WM_SIZE, the control is not created yet.
Have to test this in WM_SIZE

:)
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Your callback routine is called 'Form1_Callback', does that mean, you
create one callback routine for every Form?

This doesn't work. In PB, you can only have one Callback at this time, and
this one will get all Events for all Windows created with PB.
(each call to SetWindowCallback() sets a new Procedure to be this
callback, so if you create more then one of these Form_Callbacks, only the
last one that was set using SetWindowCallback() will receive any
messages.

So you have to create one callback only, and decide there with the
Window parameter of the Message, which Window the message came
from.

Timo
quidquid Latine dictum sit altum videtur
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

Good to hear, how annoying..

Well, ehh, what ehh oops.
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

Time to use my own callbacks isn't?
(Hooking)
Post Reply