This problem is wasting a lot of time and generating a lot of dubious language!
I have a window class registered as below, which is the same as all the window classes before it:
MENUNAME= "GRAFIXMENU"
'- Register the windows class
wndclass21.cbsize = SIZEOF(WndClass21)
wndclass21.style = %CS_HREDRAW OR %CS_VREDRAW
wndclass21.lpfnWndProc =CODEPTR(LinearProc)
wndclass21.cbClsExtra = 0
wndclass21.cbWndExtra = 0
wndclass21.hInstance = hInstance
wndclass21.hIcon =LoadIcon( hInstance, "APP")
wndclass21.hcursor = LoadCursor(%NULL, BYVAL %IDC_ARROW)
wndclass21.hbrbackground = gbrush2
wndclass21.lpszMenuName = VARPTR(MENUNAME)
wndclass21.lpszClassName = VARPTR( szClassName21)
wndclass21.hIconSm = LoadIcon(hInstance, "APP")
RegisterClassEx wndclass21
This is called by the following code:
CASE 423 ' linear schematic
GoToSleep gMain 'ignore
IF dongleon=1 AND go=0 THEN EXIT SELECT 'ignore
LoadData 'ignore
hLinear=CreateWindow (szClassName21, "Linear schematic",%WS_HSCROLL OR %WS_SYSMENU, 0, 0, 750,150,gMain,hMenu3, hInst,BYVAL %NULL)
MSGBOX szClassName21+crlf+STR$(hlinear)+crlf+STR$(gMain)+crlf+STR$(hMenu3)+crlf+STR$(hInst)+crlf+STR$(factor)
CenterWindow hLinear
ShowWindow hLinear, %SW_SHOWNORMAL
UpdateWindow hLinear
The message box displays various parameters.
This runs OK first time round, but having closed the window, it will not display again if CASE 423 is called - returns 0 in hLinear
The code associated with the window is:
FUNCTION LinearProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
LOCAL NULL AS INTEGER
LOCAL lpPoint AS POINTAPI
LOCAL n AS INTEGER
LOCAL GraphText AS ASCIIZ*45
LOCAL q AS INTEGER
LOCAL redBrush AS LONG
LOCAL TotLength AS LONG
LOCAL CC1 AS INIT_COMMON_CONTROLSEX
SELECT CASE wMsg
CASE %WM_CREATE
CC1.dwSize=SIZEOF(CC1)
CC1.dwICC=%ICC_WIN95_CLASSES
InitCommonControlsEX CC1
FOR n=1 TO NoSects
IF LEFT$(drain(n),2)="1." THEN SysLength=SysLength+(length(n))
NEXT
factor=(syslength*0.2)-5
xMinScroll=1
xMaxScroll=100
xCurScroll=1
SetScrollRange hWnd ,%SB_HORZ, xMinScroll, xMaxScroll,%FALSE
SetScrollPos hWnd , %SB_HORZ, xCurScroll, %TRUE
CASE %WM_COMMAND
SELECT CASE LOWRD(wParam)
CASE 901
DestroyWindow hWnd
END SELECT
CASE %WM_HSCROLL
SELECT CASE LOWRD(wParam)
CASE %sb_lineleft
xNewpos=xCurScroll-1
SetXpos
CASE %sb_lineright
xNewpos=xCurScroll+1
SetXpos
CASE %sb_pageleft
xNewpos=xCurScroll-5
SetXpos
CASE %sb_pageright
xNewpos=xCurScroll+5
SetXpos
CASE %sb_thumbposition
xNewpos=HIWRD(wParam)
SetXpos
END SELECT
CASE %WM_PAINT
PaintLinear hWnd,xadjust
CASE %WM_DESTROY
FUNCTION =1
EXIT FUNCTION
CASE %WM_SYSCOMMAND
END SELECT
FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
It is almost as if the window class was 'unregistered' when the above function is exited.
What have I done wrong? There is one other instance of this fault happening in the program, but all the other windows work OK. I am sure there is something simple that I have missed in the last 10 hours of cursing.
Any help gratefully accepted!
Iain Johnstone
Sorry about the line breaks - all single lines in original code.
------------------
I have a window class registered as below, which is the same as all the window classes before it:
MENUNAME= "GRAFIXMENU"
'- Register the windows class
wndclass21.cbsize = SIZEOF(WndClass21)
wndclass21.style = %CS_HREDRAW OR %CS_VREDRAW
wndclass21.lpfnWndProc =CODEPTR(LinearProc)
wndclass21.cbClsExtra = 0
wndclass21.cbWndExtra = 0
wndclass21.hInstance = hInstance
wndclass21.hIcon =LoadIcon( hInstance, "APP")
wndclass21.hcursor = LoadCursor(%NULL, BYVAL %IDC_ARROW)
wndclass21.hbrbackground = gbrush2
wndclass21.lpszMenuName = VARPTR(MENUNAME)
wndclass21.lpszClassName = VARPTR( szClassName21)
wndclass21.hIconSm = LoadIcon(hInstance, "APP")
RegisterClassEx wndclass21
This is called by the following code:
CASE 423 ' linear schematic
GoToSleep gMain 'ignore
IF dongleon=1 AND go=0 THEN EXIT SELECT 'ignore
LoadData 'ignore
hLinear=CreateWindow (szClassName21, "Linear schematic",%WS_HSCROLL OR %WS_SYSMENU, 0, 0, 750,150,gMain,hMenu3, hInst,BYVAL %NULL)
MSGBOX szClassName21+crlf+STR$(hlinear)+crlf+STR$(gMain)+crlf+STR$(hMenu3)+crlf+STR$(hInst)+crlf+STR$(factor)
CenterWindow hLinear
ShowWindow hLinear, %SW_SHOWNORMAL
UpdateWindow hLinear
The message box displays various parameters.
This runs OK first time round, but having closed the window, it will not display again if CASE 423 is called - returns 0 in hLinear
The code associated with the window is:
FUNCTION LinearProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
LOCAL NULL AS INTEGER
LOCAL lpPoint AS POINTAPI
LOCAL n AS INTEGER
LOCAL GraphText AS ASCIIZ*45
LOCAL q AS INTEGER
LOCAL redBrush AS LONG
LOCAL TotLength AS LONG
LOCAL CC1 AS INIT_COMMON_CONTROLSEX
SELECT CASE wMsg
CASE %WM_CREATE
CC1.dwSize=SIZEOF(CC1)
CC1.dwICC=%ICC_WIN95_CLASSES
InitCommonControlsEX CC1
FOR n=1 TO NoSects
IF LEFT$(drain(n),2)="1." THEN SysLength=SysLength+(length(n))
NEXT
factor=(syslength*0.2)-5
xMinScroll=1
xMaxScroll=100
xCurScroll=1
SetScrollRange hWnd ,%SB_HORZ, xMinScroll, xMaxScroll,%FALSE
SetScrollPos hWnd , %SB_HORZ, xCurScroll, %TRUE
CASE %WM_COMMAND
SELECT CASE LOWRD(wParam)
CASE 901
DestroyWindow hWnd
END SELECT
CASE %WM_HSCROLL
SELECT CASE LOWRD(wParam)
CASE %sb_lineleft
xNewpos=xCurScroll-1
SetXpos
CASE %sb_lineright
xNewpos=xCurScroll+1
SetXpos
CASE %sb_pageleft
xNewpos=xCurScroll-5
SetXpos
CASE %sb_pageright
xNewpos=xCurScroll+5
SetXpos
CASE %sb_thumbposition
xNewpos=HIWRD(wParam)
SetXpos
END SELECT
CASE %WM_PAINT
PaintLinear hWnd,xadjust
CASE %WM_DESTROY
FUNCTION =1
EXIT FUNCTION
CASE %WM_SYSCOMMAND
END SELECT
FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
It is almost as if the window class was 'unregistered' when the above function is exited.
What have I done wrong? There is one other instance of this fault happening in the program, but all the other windows work OK. I am sure there is something simple that I have missed in the last 10 hours of cursing.
Any help gratefully accepted!
Iain Johnstone
Sorry about the line breaks - all single lines in original code.
------------------
Comment