Hello,
I tried creating a window using CreateWindow API with the lazurus wince binary download by CCRDude but for some reason it doesnt work. What actually seems to be happenning is that the window gets created and the window title gets displayed in next to the start button (testing on the Windows mobile 5 emulator) however rest of the screen doesnt seem to be painting the window.
I'm guessing this is a problem with my code because a normal form application seems to work and show the form.
Could someone check the following code and tell me if there is a problem.
program project1;
{$mode objfpc}{$H+}
uses
windows;
function MyWndProc(hWnd:HWND; uMsg: UINT; lParam : LPARAM; wParam : WPARAM ):LONGINT;
begin
MyWndProc:=DefWindowProc(hWnd, uMsg, wParam, lParam);
end;
procedure registerwindowclass();
var
wndclass : TWndClass;
begin
wndclass.style := CS_HREDRAW or CS_VREDRAW;
wndclass.lpfnWndProc := @MyWndProc; // window procedure: mandatory
wndclass.cbClsExtra := 0;
wndclass.cbWndExtra := 0;
wndclass.hInstance := HINSTANCE; // owner of the class: mandatory
wndclass.hIcon := 0;
wndclass.hCursor := 0;
wndclass.hbrBackground := HBRUSH(COLOR_WINDOW+1);
wndclass.lpszMenuName := nil;
wndclass.lpszClassName := 'MAS_TEST_FORM'; // mandatory
if RegisterClass(@wndclass)=0 then
MessageBox(0,'Window Resgistration Failed','Error',0);
end;
var
handle:HWND;
msg:tagMSG;
begin
RegisterWindowClass();
handle:=CreateWindow('MAS_TEST_FORM', 'test', WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, HInstance, nil);
if handle=0 then
begin
MessageBox(0,'Window Creation failed','Error',0);
end;
while GetMessage (@msg, 0, 0, 0) do
DispatchMessage (@msg);
end.
P.S. i translated this from a working C++ code so i can't figure out what is wrong.