Greetings and a happy new year.
If the code runs below, then I receive a funny result in the 2. MSGBOX.
The 1. MSGBOX shows me the value 20. That is okay. But the 2. MSGBOX shows 10.
Is there inside the WndProc only a limited use of global variables allowed?
Please can somebody explain me this conduct.
Thank you
Norbert
(PBWin 7.04 / Win 98 SE)
If the code runs below, then I receive a funny result in the 2. MSGBOX.
The 1. MSGBOX shows me the value 20. That is okay. But the 2. MSGBOX shows 10.
Is there inside the WndProc only a limited use of global variables allowed?
Please can somebody explain me this conduct.
Thank you
Norbert
(PBWin 7.04 / Win 98 SE)
Code:
#COMPILE EXE #DIM ALL #INCLUDE "WIN32API.INC" GLOBAL hWndMain AS LONG GLOBAL g_var AS LONG FUNCTION WINMAIN (BYVAL hInstance AS LONG, _ BYVAL hPrevInstance AS LONG, _ lpCmdLine AS ASCIIZ PTR, _ BYVAL iCmdShow AS LONG) AS LONG LOCAL Msg AS tagMsg LOCAL w_ndclass AS WndClassEx LOCAL szClassName AS ASCIIZ * 80 LOCAL hWnd AS LONG LOCAL hMenu AS LONG szClassName = "MYPROGRAM32" w_ndclass.cbSize = SIZEOF(W_ndClass) w_ndclass.style = %CS_HREDRAW OR %CS_VREDRAW w_ndclass.lpfnWndProc = CODEPTR(WndProc) w_ndclass.cbClsExtra = 0 w_ndclass.cbWndExtra = 0 w_ndclass.hInstance = hInstance w_ndclass.hIcon = LoadIcon(hInstance, "PROGRAM") w_ndclass.hCursor = LoadCursor(%NULL, BYVAL %IDC_ARROW) w_ndclass.hbrBackground = GetStockObject(%WHITE_BRUSH) '%WHITE_BRUSH) w_ndclass.lpszMenuName = %NULL w_ndclass.lpszClassName = VARPTR(szClassName) w_ndclass.hIconSm = LoadIcon(hInstance, BYVAL %IDI_APPLICATION) RegisterClassEx w_ndclass hWndMain = CreateWindowEx(0, szClassName, _ "Test", _ %WS_OVERLAPPEDWINDOW, _ 100, _ 100, _ 700, _ 400, _ %HWND_DESKTOP, _ hMenu, _ hInstance, _ BYVAL %NULL) ShowWindow hWndMain, iCmdShow UpdateWindow hWndMain WHILE GetMessage(Msg, %NULL, 0, 0) TranslateMessage Msg DispatchMessage Msg WEND FUNCTION = msg.wParam END FUNCTION FUNCTION WndProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _ BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG g_var = 10 SELECT CASE wMsg CASE %WM_CREATE g_var = g_var + 10 MSGBOX STR$(g_var),,"1. MSGBOX" MSGBOX STR$(g_var),,"2. MSGBOX" PostQuitMessage 0 FUNCTION = 0 EXIT FUNCTION END SELECT FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam) END FUNCTION
Comment