Old 1st July 2004, 13:52   #1
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Checking dialog checkboxes

This is a checkbox control on an exe dialog (not InstallOptions)

Is there a WindowsMessage to do this, because I'd rather not have to use the System plugin with BM_SETCHECK (http://www.minigui.com/api_ref/group...__msgs.html#a1)

Cheers

-Stu
Afrow UK is offline   Reply With Quote
Old 1st July 2004, 19:18   #2
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
Did you forget SendMessage NSIS command? It does exactly the same thing as using SendMessage from System plugin (except it can't get parameters from "wparam" and "lparam", it just set).

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 1st July 2004, 20:43   #3
rsegal
Senior Member
 
rsegal's Avatar
 
Join Date: Feb 2003
Location: Toronto, Canada
Posts: 227
Yeh SendMessage will do it. I'ved used it for working with checkboxes as follows...

PHP Code:
SendMessage $R1 ${BM_SETCHECK1 0 
To set the checkbox state. I believe changing the 1 to 0 will turn the checkbox off.

PHP Code:
SendMessage $R1 ${BM_GETSTATE0 0 $R2 
To get the checkbox state and $R2 will contain either 1 or 0 depending on if the checkbox is checked or not.
rsegal is offline   Reply With Quote
Old 1st July 2004, 22:03   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Yes, but wheres the BM_SETCHECK define? It's not in WinMessages.nsh (not the one that I have anyhow)

-Stu
Afrow UK is offline   Reply With Quote
Old 1st July 2004, 22:18   #5
rsegal
Senior Member
 
rsegal's Avatar
 
Join Date: Feb 2003
Location: Toronto, Canada
Posts: 227
No it isn't you have to add it. It's in some windows header file if you really want to look it up. Just type in BM_SETCHECK in any source file in visual studio and select "go to definition". That'll give you the value or just copy the following...

!define BM_GETSTATE 0x00F2
!define BM_SETCHECK 0x00F1
rsegal is offline   Reply With Quote
Old 1st July 2004, 22:23   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
That's what I've been trying to find (must reinstall VB!)

Thanks

-Stu
Afrow UK is offline   Reply With Quote
Old 3rd July 2004, 02:00   #7
bluenet
Senior Member
 
Join Date: Mar 2004
Posts: 138
Thanks rsegal.Now I have another question: how can I send message to change a droplist box state?A sample ini file like this
PHP Code:
[Settings]
NumFields=1

[Field 1]
Type=Droplist
Text
=Droplist
State
=1
ListItems
=1|2|3
Left
=77
Right
=174
Top
=27
Bottom
=119 
Default state is "1",I want to send a message cause it change to "2".
bluenet is offline   Reply With Quote
Old 3rd July 2004, 06:40   #8
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
PHP Code:
!define CB_FINDSTRINGEXACT          0x0158
!define CB_SETCURSEL                0x014E

SendMessage $hCtrl 
${CB_FINDSTRINGEXACT} -"String to be selected" $0
SendMessage $hCtrl 
${CB_SETCURSEL} $"" 

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 3rd July 2004, 11:49   #9
bluenet
Senior Member
 
Join Date: Mar 2004
Posts: 138
I test deguix's code,but not work.These is my code
PHP Code:
Name                 "Test"
OutFile              ".\test.exe"
Caption              "Test"
SetCompressor        lzma
ShowInstDetails      show
!include             MUI.nsh

  Page custom SetCustom LeaveCustom
    
  
!insertmacro MUI_PAGE_INSTFILES
  
!insertmacro MUI_LANGUAGE English

Section
SectionEnd

Function SetCustom
  InstallOptions
::initDialog /NOUNLOAD "$PLUGINSDIR\test2.ini"
    
Pop $9
     InstallOptions
::show
FunctionEnd

; --------------------------------------
!
define CB_FINDSTRINGEXACT          0x0158 
!define CB_SETCURSEL                0x014E 

Function LeaveCustom
    ReadINIStr $R0 
"$PLUGINSDIR\test2.ini" Settings State
  StrCmp $R0 0 validate  
  StrCmp $R0 2 droplist  
    Abort
    
    droplist
:
    
ReadINIStr $"$PLUGINSDIR\test2.ini" "Field 2" State
  GetDlgItem $R1 
$9 1200
    SendMessage $R1 
${CB_FINDSTRINGEXACT} -$$
    SendMessage $R1 
${CB_SETCURSEL} $""    
    
;EnableWindow $R1 0
    Abort
    
    validate
:
FunctionEnd    

Function .onInit
  InitPluginsDir
    File 
"/oname=$PLUGINSDIR\test2.ini" ".\test2.ini"
FunctionEnd 
And these is my ini file
PHP Code:
Ini file generated by the HM NIS Edit IO designer.
[
Settings]
NumFields=2

[Field 1]
Type=Droplist
Text
=Droplist
State
=1
ListItems
=1|2|3
Left
=61
Right
=218
Top
=6
Bottom
=100

[Field 2]
Type=Droplist
Text
=Droplist
Flags
=NOTIFY
State
=1
ListItems
=1|2|3
Left
=62
Right
=220
Top
=60
Bottom
=151 
I want droplist 2 control droplist 1.What wrong for me?
bluenet is offline   Reply With Quote
Old 3rd July 2004, 19:32   #10
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
I thought it would not work because of that -1 I put for ${CB_FINDSTRINGEXACT}. MSDN says that if wparam is -1 it would search the whole list, but that doesn't happen. Put 0 on its place.

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 3rd July 2004, 23:54   #11
bluenet
Senior Member
 
Join Date: Mar 2004
Posts: 138
I replaceed -1 with 0,but still not work.
bluenet is offline   Reply With Quote
Old 4th July 2004, 07:31   #12
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
Hmmm... Aparently there is a problem with SendMessage from NSIS. Everytime I change the number in wparam and/or lparam it should return the correct index of the item (it now returns 0). This is the correct (tested this time):

code:
!define CB_FINDSTRINGEXACT 0x0158
!define CB_SETCURSEL 0x014E

System::Call 'user32::SendMessageA(i R1, i ${CB_FINDSTRINGEXACT}, i -1, t r1)i .r0'
System::Call 'user32::SendMessageA(i R1, i ${CB_SETCURSEL}, i r0,)'


My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 4th July 2004, 10:18   #13
bluenet
Senior Member
 
Join Date: Mar 2004
Posts: 138
I got a idear to do it

PHP Code:
!define CB_GETCURSEL                0x0147 
!define CB_SETCURSEL                0x014E
GetDlgItem $R1 $HWND 1201
SendMessage $R1 
${CB_GETCURSEL} -1 0 $R2    
GetDlgItem $R1 $HWND 1200
SendMessage $R1 
${CB_SETCURSEL$R2 0 
bluenet 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