hphantom
3rd October 2011 15:58 UTC
Endless Marquee in nsWindows popup
Hi everyone,
Am using the nsWindows plugin to create popups, and almost have the marquee working. My intention was to generate the marquee whenever some work is being done (function being called, etc), just so the user had some some that something was moving.
I managed to get the popup to show just fine, but the marquee itself is not - it's just blank.
This is the main page:
Function OnClickLookup
EnableWindow $HWNDPARENT 1
${NSW_CreateWindow} $WINDOW "Look up your key" 1044
;set window size
${NSW_SetWindowSize} $WINDOW 400 200
${NSW_CenterWindow} $WINDOW $hwndparent
${NSW_CreateLabel} 40 90 80 20 "Email Address:"
Pop $0
${NSW_CreateText} 140 90 200 20 $email
Pop $emailTextBox
${NSW_CreateButton} 100 130 85 30 "&Find my key"
Pop $GETKEY
${NSW_OnClick} $GETKEY onClickGetKey
${NSW_Show}
FunctionEnd
This is the leave code (onClickGetKey):
Function onClickGetKey
${NSW_GetText} $fullNameTextBox $fullName
${NSW_GetText} $emailTextBox $email
; We require a valid email address to verify the activation, for all users
push "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
push $email
SFNSIUtil::regMatch
pop $R1 ;true/false
${IF} $R1 == "false"
${ORIF} $R1 == ""
Messagebox MB_OK|MB_ICONEXCLAMATION "Your email is invalid." IDOK errors
${ELSE}
call Timer
push $email
push $productcode
S:GetKey
pop $0
Push " " ;divider char
Push $0 ;input string
Call SplitFirstStrPart
Pop $R0 ;1st part ["string1"]
${IF} $R0 == "ERROR"
${ORIF} $R0 == "RPC"
call destroyTimerWindow
Messagebox MB_OK|MB_ICONEXCLAMATION "$0"
${ELSE}
call destroyTimerWindow
MessageBox MB_OK|MB_SETFOREGROUND "Your License Key has been sent to your email."
${ENDIF}
${ENDIF}
errors:
StrCpy $R9 "0"
Call RelGotoPage
FunctionEnd
And this is my timer code:
Function Timer
${NSW_CreateWindow} $TIMER "Submitting" 1044
${NSW_SetWindowSize} $TIMER 250 50
${NSW_CenterWindow} $TIMER $WINDOW
${NSW_CreateProgressBar} 0 0 100% 100% "Submitting"
Pop $hwnd
${NSW_AddStyle} $hwnd ${PBS_MARQUEE}
${NSW_CreateTimer} NSW_Timer.Callback 10
${NSW_Show}
FunctionEnd
Function NSW_Timer.Callback
${NSW_KillTimer} NSW_Timer.Callback ; Kill the timer
SendMessage $hwnd ${PBM_SETMARQUEE} 1 50 ; start=1|stop=0 interval(ms)=+N
${NSW_Show}
FunctionEnd
Function destroyTimerWindow
${NSW_DestroyWindow} $TIMER
FunctionEnd
I've also attached a screencap of what am seeing. Am thinking I have the wrong Window?
Afrow UK
3rd October 2011 18:41 UTC
This probably isn't working because the window is running in the same thread as your process and therefore the window cannot repaint (the window message loop is blocked). Also a progress bar is either in marque mode or it isn't. You don't need to send PBM_SETMARQUEE every so often; only once.
Stu
hphantom
3rd October 2011 19:07 UTC
Ok, I fixed that part with the marquee mode, but am still stumped on the same thread/process. How can I find what thread/process the code is running in so I don't overlap them?
T.Slappy
4th October 2011 06:14 UTC
I think problem is in NSW. I did not looked into sources but if it is similar to nsDialogs all components [also the timer] are created in one thread = GUI thread which is bad.
Originally posted by hphantom
How can I find what thread/process the code is running in so I don't overlap them?
Normally when you start new thread you get its ID so every thread is unique. try using this ID to recognize correct thread.
Use my ThreadTimer plugin as reference:
http://nsis.sourceforge.net/ThreadTimer_plug-in
By the way I am developing new plug-in specially with this purpose - it creates new separated thread which shows window with Please wait... message and gif animation :)
hphantom
4th October 2011 13:32 UTC
I will definitely try your plug-in, Slappy.
It's strange, I got it to work within 2 pop-ups, not 3. (So if I have a button to click and pops up a window, that gives me the marquee, but if I have a button to click, which pops up a window with another button to click, that doesn't pop up.)
Edit: I tried the ThreadTimer, Slappy, but not sure why it's not working either. I dropped in the DLL into my plugins folder and linked it to my installer. I compiled/built the C code; and I copied your test code but it says that ThreadTimer is invalid. Am I missing something? Should there be an NSH/I header somewhere?
T.Slappy
5th October 2011 07:17 UTC
Originally posted by hphantom
Edit: I tried the ThreadTimer, Slappy, but not sure why it's not working either. I dropped in the DLL into my plugins folder and linked it to my installer. I compiled/built the C code; and I copied your test code but it says that ThreadTimer is invalid. Am I missing something? Should there be an NSH/I header somewhere?
Maybe you have problem with decorating functions? Try:
http://forums.winamp.com/showthread....92#post2807692
Anyway you can take an idea from that plug-in - creating new thread using
_beginthreadex
hphantom
5th October 2011 14:19 UTC
Originally posted by T.Slappy
Maybe you have problem with decorating functions? Try: http://forums.winamp.com/showthread....92#post2807692
Anyway you can take an idea from that plug-in - creating new thread using _beginthreadex
That's exactly the issue am having, all that extra fluff shows up.
Start@@YAXPAUHWND__@@HPADPAPAU_stack_t@@PAUextra_parameters@@@Z
Is there any way to fix this (or any idea how to)?