Recent

Author Topic: my programs crash  (Read 2427 times)

d2010

  • Full Member
  • ***
  • Posts: 121
Re: my programs crash
« Reply #15 on: February 13, 2025, 02:36:47 am »
00=First you add MainFunction. You rename my function  "flistsvc_lomain" with your "nameMAIN"
01=Before  the DestroyWindow(, then you you add while...dispatchMessage..end
02=You add this procedure ,exactly this name "flistsvc_lbwndproc"
03=You search flistsvc_lbwndproc at Function flistsvc_lomain(h

Code: [Select]
Function  flistsvc_lbwndproc(hWnd: HWND; message: UINT;  wParam: WPARAM;  lParam: LPARAM): LRESULT;
Begin
    Assert_cxx(523);
    mtjig_before:=nt_itoa(Message)+'=';
    str_fileechoPASCAL(ktoolfini_flistsvc32ini,mtjig_before);
    mtjig_before:='';
    case Message of
         WM_CREATE : Begin message_wm_create;
                     End;
//          WM_CTLCOLORLISTBOX,
          WM_SETFOCUS : Begin   SetFocus (a14_getvar[04].handr) ;
                                result:=0;
                                exit;
                         End;

          WM_KEYDOWN :  ShowKey (hwnd, 0, 'WM_KEYDOWN', wParam, lParam) ;
          WM_KEYUP :    ShowKey (hwnd, 0, 'WM_KEYUP', wParam, lParam) ;
          WM_CHAR :     ShowKey (hwnd, 1, 'WM_CHAR', wParam, lParam) ;
          WM_DEADCHAR :  ShowKey (hwnd, 1, 'WM_DEADCHAR', wParam, lParam) ;
          WM_SYSKEYDOWN :ShowKey (hwnd, 0, 'WM_SYSKEYDOWN', wParam, lParam) ;
          WM_SYSKEYUP :  ShowKey (hwnd, 0, 'WM_SYSKEYUP', wParam, lParam) ;
          WM_SYSCHAR :  ShowKey (hwnd, 1, 'WM_SYSCHAR', wParam, lParam) ;
          WM_SYSDEADCHAR :ShowKey (hwnd, 1, 'WM_SYSDEADCHAR', wParam, lParam) ;

         WM_COMMAND: result:=message_wmcommand(wParam,lParam);
         WM_QUIT:      Begin //ShowWindow(hWnd, SW_HIDE);
                             PostQuitMessage (0) ;
                             result:=0;
                        end;
         WM_DESTROY : Begin //ShowWindow(hWnd, SW_HIDE);
                            result:=DefWindowProc(hwnd,0, 0, 0) ;
                            //PostQuitMessage (WM_DESTROY) ;
                         end;
        else bootstat_dat;
     end;
End;
Eu multumesc tie ArsenieBoca2025.
Code: [Select]
   while(GetMessage(msg, 0, 0, 0)) do
   begin
      {$ifdef keyboard.inf}
        if (PeekMessage (msg,0, 0, 0, PM_REMOVE)) then
          if  keyboard_inf_loc then break;
      {$endif}
      TranslateMessage(msg);
      DispatchMessage(msg);
   end;
   result:=errorlevel+100;
   DestroyWindow(hWnd);
end;
Code: [Select]
Function flistsvc_lomain(hInstance : HINST; hPrevInstance : HINST;lpCmdLine : PChar; nCmdShow : Integer;libraryTD_Db,pidonertf:strff) : Integer;
var
  hWnd     : THandle;
  Msg      : TMsg;
  wndClass : TWndClass;
  adcstate:boolean;

       Function  keyboard_inf_loc:boolean;
          Begin  result:=(msg.message = WM_QUIT);
                 writeln('(jey=',msg.message);
                  if (result) then exit;
                  if msg.message = WM_KEYDOWN then
                     case MapVirtualKey (msg.wparam, 0) of
                      13..255: writeln('*****');
                    end;
           End;


begin
   kscreensize.y:=GetSystemMetrics(SM_CYSCREEN);Assert_cxx(512);
   kscreensize.x:=GetSystemMetrics(SM_CXSCREEN);
   adcstate:=(HIWORD(nCmdShow)=WM_VSCROLL);
   if adcstate then
     Begin  hwnd:=LOWORD(nCmdShow);
            if (hwnd<1) then hwnd:=0;
            if (hwnd>77) then hwnd:=77;   //rem:   77.procente
             with kscreensize do  hwnd:=hwnd*y div 100;
     End;
   imagedef.h.resolutionunits:=if_int(adcstate,hwnd,0);
   hwnd:=0;
   wndClass.style          := CS_HREDRAW or CS_VREDRAW;
   wndClass.lpfnWndProc    := @flistsvc_lbwndproc;
   wndClass.cbClsExtra     := 0;
   wndClass.cbWndExtra     := 0;
   wndClass.hInstance      := hInstance;
   wndClass.hIcon          := LoadIcon(0, IDI_APPLICATION);
   wndClass.hCursor        := LoadCursor(0, IDC_ARROW);
   wndClass.hbrBackground  := HBRUSH(GetStockObject(WHITE_BRUSH));
   wndClass.lpszMenuName   :=nil;
   wndClass.lpszClassName  :='GettingStarted';
   RegisterClass(wndClass);
   errorlevel:=0;
   size3_rm_cur.y:=Integer(CW_USEDEFAULT);
   size3_rm_cur.x:=Integer(CW_USEDEFAULT);

   if (length(libraryTD_Db)<2) then libraryTD_Db:=kNsiMessageLength_i02 else
   if (fileexists(libraryTD_Db)) then libraryTD_Db:=concat('(FListSVc "',ExtractFile2Name('',libraryTD_Db),'?>',pidonertf,'")'#0#0#0) else
   if (pos('.',libraryTD_Db)>0) then libraryTD_Db:=concat('(FlisTSvc "',ExtractFile2Name('',libraryTD_Db),
        '?=',pidonertf,'")'#0#0#0) else
       libraryTD_Db:=kNsiMessageLength_i02;
   Assert_cxx(513);
   hWnd := CreateWindow(
      'GettingStarted',       // window class name
      @A14_dwgtitled[1],    // window caption
      WS_CAPTION or WS_THICKFRAME or WS_MAXIMIZEBOX ,    // window style
      Integer(CW_USEDEFAULT), // initial x position
      Integer(CW_USEDEFAULT), // initial y position
      size3_rm_cur.x, // initial x size width
      size3_rm_cur.y, // initial y size
      0,                      // parent window handle
      0,                      // window menu handle
      hInstance,              // program instance handle
      nil);                   // creation parameters


   ShowWindow(hWnd, SW_SHOW);
   UpdateWindow(hWnd);

   while(GetMessage(msg, 0, 0, 0)) do
   begin
      {$ifdef keyboard.inf}
        if (PeekMessage (msg,0, 0, 0, PM_REMOVE)) then
          if  keyboard_inf_loc then break;
      {$endif}
      TranslateMessage(msg);
      DispatchMessage(msg);
   end;
   result:=errorlevel+100;
   DestroyWindow(hWnd);
end;//off-flistsvc_lbmain("")


Thaddy

  • Hero Member
  • *****
  • Posts: 16665
  • Kallstadt seems a good place to evict Trump to.
Re: my programs crash
« Reply #16 on: February 13, 2025, 07:11:24 am »
Please use code=pascal between brackets
The coding style on its own is horrible enough, so a better view of what is happening is appreciated
But I am sure they don't want the Trumps back...

Nitorami

  • Hero Member
  • *****
  • Posts: 508
Re: my programs crash
« Reply #17 on: February 13, 2025, 10:26:30 am »
The OP is a novice and may not know that GUI programs in Lazarus can be made without calls to the windows API ?

440bx

  • Hero Member
  • *****
  • Posts: 5081
Re: my programs crash
« Reply #18 on: February 13, 2025, 10:42:57 am »
is the forum not replacing the book?
No.  The forum participants will gladly help but, they are not here to teach you or anyone else how to program.

was that not simply enough, that everybody know how to code this?
It doesn't matter if everyone knows how to code this, if you don't have the knowledge to understand the "solution" (which your questions have made clear, you don't.)

with what must the queue filled up and for whom?
i ask there only for mouse and keyboard, but the program crashes.
this problem is not solved, and why?
and why the window-handle needs informations, when the
code-part shall know keyboard and mouse instead all?
what can be messaged around no participiant parts of what ever,
so that it not crash?
if you took the time to read a good Windows book, you'd know the answers to those questions and many more.

You have to have the minimum necessary knowledge to understand the answers to the questions you have.  You got to make an effort, help yourself.  Nothing can take the place of that.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018