Old 10th March 2006, 15:30   #1
Jamyn
Junior Member
 
Join Date: Aug 2002
Location: Texas
Posts: 36
Unminimize solution?

Hi all,

I noticed that this wiki page, which talks about setting a mutex and only allowing one copy of the installer to run, has been updated.

Someone updated the page with an advanced example that will check for the installer, and if someone tries to launch two copies - it will set the first one as the active window instead.

Now I know this is a tiny thing, but if the user has (for some reason) minimized the first installer window, the example will indeed set the first one as the active window. But, it will not "pop" it back up from being minimized. At least this is the case when testing on Windows XP.

Do any of you smart people know the proper way to add the functionality to this example? I thought it would be a useful addition to the advanced example, but don't want to modify it in an unportable way.

*wishes he knew a lot more... ok anything.. about windows api stuff* ;)

Thanks,

-J
Jamyn is offline   Reply With Quote
Old 10th March 2006, 15:42   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
You can try adding a call to ShowWindow:
code:
!include WinMessages.nsh
ShowWindow $1 ${SW_SHOW}


NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 10th March 2006, 15:44   #3
Jamyn
Junior Member
 
Join Date: Aug 2002
Location: Texas
Posts: 36
Thanks

Thanks Kichik -- I drink from your fountain of knowledge regularly Much appreciated.
Jamyn is offline   Reply With Quote
Old 10th March 2006, 16:03   #4
Jamyn
Junior Member
 
Join Date: Aug 2002
Location: Texas
Posts: 36
How about this?

I will say up front - I'm very much grasping at thin air here, and "guessing" on the format of the extra line:

Is this a proper way to add this functionality in a portable way? (ie: not requiring the WinMessages include)? It does seem to work when I test it, but that does't mean it's the "right" way, that it won't blow up, etc.

code:

System::Call "kernel32::CreateMutexA(i 0, i 0, t '$(^Name)') i .r0 ?e"
Pop $0
StrCmp $0 0 launch
StrLen $0 "$(^Name)"
IntOp $0 $0 + 1
loop:
FindWindow $1 '#32770' '' 0 $1
IntCmp $1 0 +4
System::Call "user32::GetWindowText(i r1, t .r2, i r0) i."
StrCmp $2 "$(^Name)" 0 loop
System::Call "user32::SetForegroundWindow(i r1) i."
System::Call "user32::ShowWindow(i r1) i."
; ShowWindow $1 ${SW_SHOW}
Abort
launch:
FunctionEnd

Jamyn is offline   Reply With Quote
Old 10th March 2006, 16:11   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
WinMessages.nsh is included in the NSIS package, it's portable enough. There's no need to use the System plug-in when you've got ShowWindow as a built-in instruction. You can use the code I've put above as-is.

Your current code is missing an argument for ShowWindow. You passed only the window handle and forgot the requested show command.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 11th March 2006, 04:13   #6
Jamyn
Junior Member
 
Join Date: Aug 2002
Location: Texas
Posts: 36
Sorry to mis-state what I meant. I have the flu, and have been quite medicated for the last few days. I find it hard to articulate correctly (not that I do much better of a job when I'm not sick, but...

I of course am not implying you write non-portable code What I mean to say is, I wanted to apply that one extra piece of the puzzle, to the current wiki entry. So I wanted to add the line using the same "style" as the wiki entry author - the author used the System:: method.

Perhaps I will just add another example, using the WinMessages style of doing things instead of using the System:: calls. Thanks again for your feedback to my question.
Jamyn 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