Advertisement

Frustrating delphi problem.

Started by January 11, 2000 05:19 AM
-1 comments, last by ggs 24 years, 11 months ago
Hi. I have been trying to get this to work for about a week but with NO luck. I've been trying to register and create a simple window. I have to do these basics so I can go on to better things. The thing is When i use my windowproc it doesnt work but when i used the default one it does! I know when you call createwindow it sends 3 msg to the windowproc so whats not working? So here is the code. Not all of it but about 90%. program window; uses windows, logger in 'logger.pas', Messages in '..\..\Source\Rtl\Win\messages.pas'; // this funcion will handle all messages sent to this app function WindowProc(hwnd_ : handle; // handle of window Msg_ : UINT; // message identifier wParam_ :WPARAM; // first message parameter lParam_ :LPARAM): dword; // second message parameter begin // records the all msg sent to this proc log_action('Msg send to wndproc. Msg code = ' + dec2hex(Msg_)); // let windows handle anything this app doesnt result := defWindowProc(hwnd_,Msg_,wParam_,lParam_); log_action('Result of processing msg = ' + dec2hex(result)); end; {WindowProc} var { temp_error_code : dword; } wndclass_ : wndclass; win_main_handle : handle; tempresult : integer; msg_ : tagmsg; // record to hold a msg the app has to process begin log_action('Default windowproc address @ '+ dec2hex(longword(@defwindowproc))); log_action('App windowproc address @ '+ dec2hex(longword(@windowproc))); log_action; wndclass_.style := CS_DBLCLKS or CS_OWNDC or CS_HREDRAW or CS_VREDRAW; wndclass_.lpfnwndproc := @WindowProc; wndclass_.cbclsextra := 0; wndclass_.cbwndextra := 0; wndclass_.Hinstance := sysinit.Hinstance; wndclass_.Hicon := Loadicon(0,IDI_APPLICATION); wndclass_.Hcursor := Loadcursor(0,IDC_ARROW); wndclass_.hbrbackground := Getstockobject(white_brush); wndclass_.lpszmenuname := nil; wndclass_.lpszclassname := '_WinTetris_'; // STUPID delphi // api calls CAN NOT be put in if statments!! tempresult := registerclass(wndclass_); if tempresult = 0 then begin messagebox(0,'Critical Error : Unable to register Window Class','WinTetris',mb_ok); log_action; log_action('Critical Error : Unable to register Window Class'); halt; // quits end; win_main_handle := createwindow( wndclass_.lpszclassname, // The window class name 'WinTetris', // Title of the window WS_Overlappedwindow or WS_VISIBLE, // flags 100,100, // position 320,200, // size 0, // Handle to parent 0, // Handle to menu Hinstance, // instance from WinMain nil); if win_main_handle = 0 then begin { temp_error_code := getlasterror; FormatMessage()} messagebox(0,'Critical Error : Unable to create Window Class','WinTetris',mb_ok); log_action; log_action('Critical Error : Unable to create Window Class'); halt; // quits end; ... The code after here never gets used. The procedure log_action sends the parameter to a log file The unit Messages is JUST the declaration of the msgs Thanks for any help. This board is great, always get some type of answer. The window successfully works when wndclass_.lpfnwndproc := @defWindowProc is wndclass_.lpfnwndproc := @WindowProc; Here are the msg send to my windowproc that were captured by log_action. 19:4:37:460/Msg send to wndproc. Msg code = $8BE4 19:4:37:460/Result of processing msg = $00 19:4:37:460/Msg send to wndproc. Msg code = $8C38 19:4:37:460/Result of processing msg = $00 19:4:37:460/Msg send to wndproc. Msg code = $8C36 19:4:37:460/Result of processing msg = $00 Hope this extra info helps. Again thanks for any help. Edited by - ggs on 1/11/00 5:45:43 AM

This topic is closed to new replies.

Advertisement