View Single Post
  #4  
Old 30-12-2020, 18:08
Cesar82's Avatar
Cesar82 Cesar82 is offline
Registered User
 
Join Date: May 2011
Location: Brazil
Posts: 1,077
Thanks: 1,835
Thanked 2,311 Times in 789 Posts
Cesar82 is on a distinguished road
Quote:
Originally Posted by Cuttlas View Post
Hi
I use several plugins and modules within my setup, such as WinTB, botva2, progressBar, Trackbar.
They will use SetWindowLong and I should release them in the correct situation. But sometimes I do not know where to release and so on ... So the setup will delay on Exit and will close with an error in the debugger (most with 0xc000041d exit code).

How to trace the problem and release the WindowLong? any idea or similar Experience?
If you loaded any PROC with SetWindowlong it is necessary to restore the previous values.
Example:
Code:
const
  GWL_WNDPROC = (-4);
  SC_MINIMIZE = $F020;
  WM_SYSCOMMAND = $0112;

var
  OldProc: Longint;

function CallWindowProc(lpPrevWndFunc: Longint; hWnd: HWND; Msg: UINT; wParam, lParam: Longint): Longint; external '[email protected] stdcall delayload';
function SetWindowLong(hWnd: HWND; nIndex: Integer; dwNewLong: Longint): Longint; external '[email protected] stdcall delayload';

function WindowProc(hWnd: HWND; uMsg, wParam, lParam: Longint): Longint;
begin
  //code here
  Result := CallWindowProc(OldProc, hWnd, uMsg, wParam, lParam);
end;

procedure InitializeWizard();
begin
  OldProc := SetWindowLong(WizardForm.Handle, GWL_WNDPROC, CreateCallBack(@WindowProc));
end;

procedure DeinitializeSetup();
begin
  SetWindowLong(WizardForm.Handle, GWL_WNDPROC, OldProc);
end;
If you use Timers calling SetTimer they must also be terminated with KillTimer.
Reply With Quote
The Following 2 Users Say Thank You to Cesar82 For This Useful Post:
Cuttlas (30-12-2020), ffmla (30-12-2020)