Old 25th January 2018, 19:24   #1
sfx09
Junior Member
 
Join Date: Jul 2017
Posts: 27
stop 'back' message in plugin

Hello!

I'm doing a plugin for NSIS with a several forms (!), which are changing by clicking on 'Next' or 'Back' buttons.
My plugin work via Page Custom at this steps-condition:

!insertmacro MUI_PAGE_WELCOME
Page Custom MyPlugShow
!insertmacro MULTIUSER_PAGE_INSTALLMODE

Also, I try to change 'Cancel' button to Skip-functionality. So, if I try to click on 'Skip' ('Cancel') button, after click on the 'Next' button - all work fine - plugin go to MULTIUSER_PAGE_INSTALLMODE. But, if I try to click on 'Skip', after click on the 'Back' button - plugin page go to MUI_PAGE_WELCOME.

Please help me fix this.

Catching 'Skip' from plugin CurrentParentProc (Delphi):

PHP Code:
  if (uMsg WM_COMMANDthen
  begin
    
//esc or skip button
    
if (LOWORD(wParam) = 2) and (HIWORD(wParam) = BN_CLICKEDthen
    begin
      
//ShowMessage('here click skip and skip on ESC!!!');
      
bStopPlugin := TRUE;
      
bSkipActivation := TRUE;
    
end;
//...
  
end

Boolean bStopPlugin - it is a "flag" for translate messages:

PHP Code:
  while bStopPlugin FALSE do
  
begin
    GetMessage
(Msg000);
    if (
not IsDialogMessage(PluginDialogFirstForm.HandleMsg)) and (not IsDialogMessage(g_hwndParentMsg))  then
    begin
      TranslateMessage
(Msg);
      
DispatchMessage(Msg);
    
end;
  
end
After, bSkipActivation - it is flag for skip. Also, I'm tried push 'next' in this statement, but - no luck.

PHP Code:
    if bSkipActivation TRUE then
    begin
      
//NSIS_PushString_Ansi('next');
      
SetWindowLongPtr(g_hwndParentSizeOf(LRESULT), Longint(parentOriginalWndproc));
      Exit;
    
end

Sorry for my English. Help me, please.
sfx09 is offline   Reply With Quote
Old 26th January 2018, 17:46   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,872
The steps
Quote:
But, if I try to click on 'Skip', after click on the 'Back' button - plugin page go to MUI_PAGE_WELCOME.
are unclear to me, please describe in more detail.

Are you eating the WM_COMMAND message in your subclass?

Post the WM_NOTIFY_OUTER_NEXT message to hwndParent with wParam=1 to go to the next page.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 26th January 2018, 19:13   #3
sfx09
Junior Member
 
Join Date: Jul 2017
Posts: 27
Quote:
Originally Posted by Anders View Post
The steps are unclear to me, please describe in more detail.

Are you eating the WM_COMMAND message in your subclass?
Yes. In my procedure, where creating delphi-form, I wrote this:

PHP Code:
  PluginDialogFirstForm := TPluginDialogFirstForm.CreateParented(g_hwndParent);
  
parentOriginalWndproc := TFNWndProc(SetWindowLongPtr(g_hwndParentSizeOf(LRESULT), Longint(@CurrentParentProc)));
  
SendMessage(g_hwndParentWM_NOTIFY_CUSTOM_READYPluginDialogFirstForm.Handle0);
  
PluginDialogFirstForm.Show

  while 
bStopPlugin FALSE do
  
begin
    GetMessage
(Msg000);
    if (
not IsDialogMessage(PluginDialogFirstForm.HandleMsg)) and (not IsDialogMessage(g_hwndParentMsg))  then
    begin
      TranslateMessage
(Msg);
      
DispatchMessage(Msg);
    
end;
  
end;

  if 
bStopPlugin TRUE then
  begin
    PluginDialogFirstForm
.Close;
    
PluginDialogFirstForm.Free;
    if 
bSkipActivation TRUE then
    begin
      
//NSIS_PushString_Ansi('next');
      
SetWindowLongPtr(g_hwndParentSizeOf(LRESULT), Longint(parentOriginalWndproc));
      
ShowMessage('bSkipActivation!');
      Exit;
    
end;
    if 
bCancelClk TRUE then
    begin
      NSIS_PushString_Ansi
('cancel');
      
Halt(0);
    
end;
    if 
bBackClk TRUE then
    begin
      
//NSIS_PushString_Ansi('back');
      
SetWindowLongPtr(g_hwndParentSizeOf(LRESULT), Longint(parentOriginalWndproc));
      Exit;
    
end;
    if 
bNextClk TRUE then
    begin
        PluginDialogFirstForm
.Hide;
        
PluginDialogSecondForm.Show;
    
end;
  
end
It's CurrentParentProc full code for plugin:

PHP Code:
function CurrentParentProc(hwndHWNDuMsgUINTwParamWPARAMlParamLPARAM): LRESULTstdcall;
var
  
wParLongInt;
begin
    
if (uMsg UINT(WM_NOTIFY_OUTER_NEXT)) then   //1032
    
begin
      wPar 
:= LongInt(wParam);
      
//
      
if (wPar 120then
      begin
        bCancelClk 
:= TRUE;
        
bStopPlugin := TRUE;
        
//MessageBox(hwnd, PChar('exit'), PChar('-'), MB_OK);
      
end;
      if (
wPar = -1then
      begin
        
// MessageBox(hwnd, PChar('back'), PChar('-'), MB_OK);
        
bBackClk := TRUE;
        
bStopPlugin := TRUE;
      
end;
      if (
wPar 1then  //next
      
begin
        bNextClk 
:= TRUE;
        
bStopPlugin := TRUE;
      
end;
    
end
    
else if (uMsg UINT(16)) then   //wm_close (X button)
    
begin
      bExitNow 
:= TRUE;
    
end
    
else if (uMsg WM_COMMANDthen
    begin
      
//esc or skip button
      
if (LOWORD(wParam) = 2) and (HIWORD(wParam) = BN_CLICKED) and (bExitNow FALSEthen
      begin
        
//ShowMessage('here click skip and skip on ESC!!!');
        
bStopPlugin := TRUE;
        
bSkipActivation := TRUE;
        
//SendMessage(g_hWndParent, WM_NOTIFY_OUTER_NEXT, 1, 0);
        
Exit(0);
      
end;
      
bExitNow := FALSE;
    
end;

  
Result := CallWindowProc(parentOriginalWndprochWnduMsgwParamlParam);
end

Quote:
Originally Posted by Anders View Post
Post the WM_NOTIFY_OUTER_NEXT message to hwndParent with wParam=1 to go to the next page.
Yes, i try this: SendMessage(g_hWndParent, WM_NOTIFY_OUTER_NEXT, 1, 0);
But, plugin go to the next Delphi-form (9 forms now in plugin), not next page installer (I need to skip all plugin work).

My code work normal, if I clicked on the 'Next' before clicking on 'Skip' (we go to the next NSIS-page). But, if I clicked on the 'Back' (it need to navigate between Delphi-forms) before clicking on 'Skip' - skipping go to previous NSIS-page.

So, if I send SendMessage(g_hWndParent, WM_NOTIFY_OUTER_NEXT, 1, 0); - I stay on same form (if I click 'Back' before 'Skip').
If I send SendMessage(g_hWndParent, WM_NOTIFY_OUTER_NEXT, 2, 0); - I goto second plugin-form, etc.

IMHO, it's not normal. Sorry, maybe I doing something wrong, but normal Delphi-source for plugin with GUI and more than one form, I can't find. =(

If such a plugin-source exists, maybe someone send me link. =)
sfx09 is offline   Reply With Quote
Old 26th January 2018, 23:41   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,872
Multiple pages are usually implemented with multiple "Page Custom xyz" instructions.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 27th January 2018, 00:29   #5
sfx09
Junior Member
 
Join Date: Jul 2017
Posts: 27
Quote:
Originally Posted by Anders View Post
Multiple pages are usually implemented with multiple "Page Custom xyz" instructions.
I need to exchange variables (and other data structures) between different modules/forms. So, the solution to multiply the pages will not work for me. The plugin really big.

But your answer about WM_NOTIFY_OUTER_NEXT working now (in other code place):

PHP Code:
    if bSkipActivation TRUE then
    begin
      SetWindowLongPtr
(g_hwndParentSizeOf(LRESULT), Longint(parentOriginalWndproc));
      
SendMessage(g_hWndParentWM_NOTIFY_OUTER_NEXT10);
      Exit;
    
end
Big thanks for help!

After all, I decided to combine all forms into one, and use the Delphi-component TPageControl to separate the user interface. I want to do this in order to avoid potential problems in the future. Try it afternoon. Thanks!
sfx09 is offline   Reply With Quote
Old 27th January 2018, 23:08   #6
sfx09
Junior Member
 
Join Date: Jul 2017
Posts: 27
Quote:
Originally Posted by sfx09 View Post
After all, I decided to combine all forms into one, and use the Delphi-component TPageControl to separate the user interface. I want to do this in order to avoid potential problems in the future. Try it afternoon. Thanks!
So, using TPageControl in this task turned out even more difficult (for subclassing). But, my plugin is normal work with many forms now (however, I had to correct the last IF-constructions in procedures with "else if"). =) I hope, in the future too.
sfx09 is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump