I modified Dave Navarro's GDI.BAS so that the window is repainted every
one or two seconds (instead of when the mouse is left-clicked), and just
let it run. After a few minutes (about 4 or 5) the app. froze. Sometimes
I can close it, no apparent harm, but other times everything is locked up
and I have to reboot. I'm using Windows 98SE, Pentium III 500 MHz, 128 MB
Ram. Here are the mods I inserted into Dave's code:
' GDI.BAS test code for PB/DLL 5.0
' by Dave Navarro, Jr. ([email protected])
..
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 wndclass AS WndClassEx
LOCAL szAppName AS ASCIIZ * 80
LOCAL hWnd AS LONG
LOCAL hTimer AS LONG
' my first added statement <------------------------------------- (1)
...
' Create a window using the registered class
hWnd = CreateWindow("GDIWINDOW",_ ' window class name
"PowerBASIC GDI Test", _ ' window caption
%WS_OVERLAPPEDWINDOW, _ ' window style
%CW_USEDEFAULT, _ ' initial x position
%CW_USEDEFAULT, _ ' initial y position
%CW_USEDEFAULT, _ ' initial x size
%CW_USEDEFAULT, _ ' initial y size
%NULL, _ ' parent window handle
%NULL, _ ' window menu handle
hInstance, _ ' program instance handle
BYVAL %NULL) ' creation parameters
hTimer = SetTimer(hWnd, 0, 1000, BYVAL %NULL) 'Timer event every 1 Secs
' my second added statement <---------------------------------------- (2)
ShowWindow hWnd, iCmdShow
UpdateWindow hWnd
WHILE GetMessage(Msg, %NULL, 0, 0)
TranslateMessage Msg
DispatchMessage Msg
WEND
' KillTimer hWnd, 0 ' Destroy the timer.. I tried with and without this
' my third added statement <--------------------------------------- (3)
FUNCTION = msg.wParam
END FUNCTION ' WinMain
...
FUNCTION WndProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
LOCAL hDC AS LONG
LOCAL LpPaint AS PaintStruct
LOCAL tRect AS Rect
STATIC First AS LONG
SELECT CASE wMsg
CASE %WM_CREATE
' CASE %WM_LBUTTONDOWN this is Dave's CASE statement
CASE %WM_Timer
' my fourth and final added statement <---------------------------- (4)
InvalidateRect hWnd, BYVAL %NULL, %TRUE
I hope this is neither too short nor too long to explain what I am having
trouble with. PBDLL 6.0 is very impressive, compared to 2.0 which I was
able to use to replace slow code in a VB 3.0 program, but I'm having a
little difficulty getting up to speed in the 32-bit environment.
Thanks to Dave and others at PB for providing so many useful examples,
such as this one. I only wish I could understand it better.
one or two seconds (instead of when the mouse is left-clicked), and just
let it run. After a few minutes (about 4 or 5) the app. froze. Sometimes
I can close it, no apparent harm, but other times everything is locked up
and I have to reboot. I'm using Windows 98SE, Pentium III 500 MHz, 128 MB
Ram. Here are the mods I inserted into Dave's code:
' GDI.BAS test code for PB/DLL 5.0
' by Dave Navarro, Jr. ([email protected])
..
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 wndclass AS WndClassEx
LOCAL szAppName AS ASCIIZ * 80
LOCAL hWnd AS LONG
LOCAL hTimer AS LONG
' my first added statement <------------------------------------- (1)
...
' Create a window using the registered class
hWnd = CreateWindow("GDIWINDOW",_ ' window class name
"PowerBASIC GDI Test", _ ' window caption
%WS_OVERLAPPEDWINDOW, _ ' window style
%CW_USEDEFAULT, _ ' initial x position
%CW_USEDEFAULT, _ ' initial y position
%CW_USEDEFAULT, _ ' initial x size
%CW_USEDEFAULT, _ ' initial y size
%NULL, _ ' parent window handle
%NULL, _ ' window menu handle
hInstance, _ ' program instance handle
BYVAL %NULL) ' creation parameters
hTimer = SetTimer(hWnd, 0, 1000, BYVAL %NULL) 'Timer event every 1 Secs
' my second added statement <---------------------------------------- (2)
ShowWindow hWnd, iCmdShow
UpdateWindow hWnd
WHILE GetMessage(Msg, %NULL, 0, 0)
TranslateMessage Msg
DispatchMessage Msg
WEND
' KillTimer hWnd, 0 ' Destroy the timer.. I tried with and without this
' my third added statement <--------------------------------------- (3)
FUNCTION = msg.wParam
END FUNCTION ' WinMain
...
FUNCTION WndProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
LOCAL hDC AS LONG
LOCAL LpPaint AS PaintStruct
LOCAL tRect AS Rect
STATIC First AS LONG
SELECT CASE wMsg
CASE %WM_CREATE
' CASE %WM_LBUTTONDOWN this is Dave's CASE statement
CASE %WM_Timer
' my fourth and final added statement <---------------------------- (4)
InvalidateRect hWnd, BYVAL %NULL, %TRUE
I hope this is neither too short nor too long to explain what I am having
trouble with. PBDLL 6.0 is very impressive, compared to 2.0 which I was
able to use to replace slow code in a VB 3.0 program, but I'm having a
little difficulty getting up to speed in the 32-bit environment.
Thanks to Dave and others at PB for providing so many useful examples,
such as this one. I only wish I could understand it better.
Comment