Hi,
I've 2 years experience in programming with VB, but this can't help me with my Problem in PB/DLL.
I already searched the Forums, but I couldn't find a answer to the following question:
I created a window with two buttons. But I can't get the ID of the Buttons. Button 1 should close the prog and Button 2 should call a Function.
Just look at the code, an you'll see what I mean:
-----------8<-----------
$COMPILE EXE "test.exe"
$INCLUDE "WIN32API.INC"
$RESOURCE "icon.PBR"
'------------------------------------------------------------------------------
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
szAppName = "TestProg"
wndclass.cbSize = SIZEOF(WndClass)
wndclass.style = %CS_HREDRAW OR %CS_VREDRAW
wndclass.lpfnWndProc = CODEPTR( WndProc )
wndclass.cbClsExtra = 0
wndclass.cbWndExtra = 0
wndclass.hInstance = hInstance
wndclass.hIcon = LoadIcon( hInstance, "TestProg" )
wndclass.hCursor = LoadCursor( %NULL, BYVAL %IDC_ARROW )
wndclass.hbrBackground = GetStockObject( %BLACK_BRUSH )
wndclass.lpszMenuName = %NULL
wndclass.lpszClassName = VARPTR( szAppName )
wndclass.hIconSm = LoadIcon( hInstance, BYVAL %IDI_APPLICATION )
RegisterClassEx wndclass
hWnd = CreateWindow(szAppName, _ ' window class name
"Only a Test", _ ' window caption
%CS_NOCLOSE, _ ' window style
%CW_USEDEFAULT, _ ' initial x position (250)
%CW_USEDEFAULT, _ ' initial y position (250)
%CW_USEDEFAULT, _ ' initial x size (300)
%CW_USEDEFAULT, _ ' initial y size (200)
%NULL, _ ' parent window handle
%NULL, _ ' window menu handle
hInstance, _ ' program instance handle
BYVAL %NULL) ' creation parameters
but1hWnd& = CreateWindow("Button", "Button1", %WS_CHILD, 210, 150, 80, 20, hWnd, 0, hInstance, 0)
but2hWnd& = CreateWindow("Button", "Button2", %WS_CHILD, 125, 150, 80, 20, hWnd, 0, hInstance, 0)
ShowWindow hWnd, iCmdShow
ShowWindow but1hWnd&, iCmdShow
ShowWindow but2hWnd&, iCmdShow
UpdateWindow hWnd
UpdateWindow but1hWnd&
UpdateWindow but2hWnd&
WHILE GetMessage(Msg, %NULL, 0, 0)
TranslateMessage Msg
DispatchMessage Msg
WEND
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
SELECT CASE wMsg
CASE %WM_CREATE
SetWindowPos hwnd, %HWND_TOP, 250, 250, 300, 200, 0
CASE %WM_COMMAND
'---------------------------------------------- here is my problem
CASE %WM_DESTROY
PostQuitMessage 0
FUNCTION = 0
EXIT FUNCTION
END SELECT
FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
'****************************************************************
'* MAIN CODE STARTS HERE *
'****************************************************************
-----------8<-----------
This doesn't work:
CASE %WM_COMMAND
SELECT CASE lowrd(wParam)
CASE but1hWnd&
SendMessage hWnd, %WM_DESTROY, 0, 0
FUNCTION = 0
EXIT FUNCTION
CASE but2hWnd&
msgbox "Hello World!"
FUNCTION = 0
EXIT FUNCTION
END SELECT
Please help me with this simple problem!
Sven
P.S.: Sorry for my bad english
------------------
[This message has been edited by Sven Mueller (edited October 02, 2000).]
I've 2 years experience in programming with VB, but this can't help me with my Problem in PB/DLL.
I already searched the Forums, but I couldn't find a answer to the following question:
I created a window with two buttons. But I can't get the ID of the Buttons. Button 1 should close the prog and Button 2 should call a Function.
Just look at the code, an you'll see what I mean:
-----------8<-----------
$COMPILE EXE "test.exe"
$INCLUDE "WIN32API.INC"
$RESOURCE "icon.PBR"
'------------------------------------------------------------------------------
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
szAppName = "TestProg"
wndclass.cbSize = SIZEOF(WndClass)
wndclass.style = %CS_HREDRAW OR %CS_VREDRAW
wndclass.lpfnWndProc = CODEPTR( WndProc )
wndclass.cbClsExtra = 0
wndclass.cbWndExtra = 0
wndclass.hInstance = hInstance
wndclass.hIcon = LoadIcon( hInstance, "TestProg" )
wndclass.hCursor = LoadCursor( %NULL, BYVAL %IDC_ARROW )
wndclass.hbrBackground = GetStockObject( %BLACK_BRUSH )
wndclass.lpszMenuName = %NULL
wndclass.lpszClassName = VARPTR( szAppName )
wndclass.hIconSm = LoadIcon( hInstance, BYVAL %IDI_APPLICATION )
RegisterClassEx wndclass
hWnd = CreateWindow(szAppName, _ ' window class name
"Only a Test", _ ' window caption
%CS_NOCLOSE, _ ' window style
%CW_USEDEFAULT, _ ' initial x position (250)
%CW_USEDEFAULT, _ ' initial y position (250)
%CW_USEDEFAULT, _ ' initial x size (300)
%CW_USEDEFAULT, _ ' initial y size (200)
%NULL, _ ' parent window handle
%NULL, _ ' window menu handle
hInstance, _ ' program instance handle
BYVAL %NULL) ' creation parameters
but1hWnd& = CreateWindow("Button", "Button1", %WS_CHILD, 210, 150, 80, 20, hWnd, 0, hInstance, 0)
but2hWnd& = CreateWindow("Button", "Button2", %WS_CHILD, 125, 150, 80, 20, hWnd, 0, hInstance, 0)
ShowWindow hWnd, iCmdShow
ShowWindow but1hWnd&, iCmdShow
ShowWindow but2hWnd&, iCmdShow
UpdateWindow hWnd
UpdateWindow but1hWnd&
UpdateWindow but2hWnd&
WHILE GetMessage(Msg, %NULL, 0, 0)
TranslateMessage Msg
DispatchMessage Msg
WEND
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
SELECT CASE wMsg
CASE %WM_CREATE
SetWindowPos hwnd, %HWND_TOP, 250, 250, 300, 200, 0
CASE %WM_COMMAND
'---------------------------------------------- here is my problem
CASE %WM_DESTROY
PostQuitMessage 0
FUNCTION = 0
EXIT FUNCTION
END SELECT
FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
'****************************************************************
'* MAIN CODE STARTS HERE *
'****************************************************************
-----------8<-----------
This doesn't work:
CASE %WM_COMMAND
SELECT CASE lowrd(wParam)
CASE but1hWnd&
SendMessage hWnd, %WM_DESTROY, 0, 0
FUNCTION = 0
EXIT FUNCTION
CASE but2hWnd&
msgbox "Hello World!"
FUNCTION = 0
EXIT FUNCTION
END SELECT
Please help me with this simple problem!
Sven
P.S.: Sorry for my bad english

------------------
[This message has been edited by Sven Mueller (edited October 02, 2000).]
Comment