Archive: Need curly buttons


Need curly buttons
  Using UMUI . I need oval shaped buttons instead of rectangle. Please advise


Anybody can help . basically any runtime API I can use to change the shape of the buttons .Needed urgently.


I don't think there's any particularly easy way to do this without defining your own controls in e.g. visual studio, then exporting them as a DLL, and then adding them to your dialogs with nsDialogs.
I could be mistaken, though.

The only semi-easy way I can think of is to build up your UI out of bitmaps and using nsDialogs' onClick event to detect a click on a bitmap and optionally toggle that bitmap (to show the user that they clicked).
That way you could define any shape of button you want.. although they would still fall into the rectangular layouts of bitmaps (like early HTML maps). This -could- be refined by using the System plugin with getWindowRect and getCursorPos to determine where in the bitmap a user clicked. Not sure how easy it would be to read out a mask bitmap to correlate the clicked position to a control's shape, though.

Below is an example showing a toggle button behavior. For a regular button you'd change the bitmap, sleep for a fraction of a second, and then change it back. ( There's no mouseDown / mouseUp events in nsDialogs )

!addincludedir "."
!addplugindir "."

!include "LogicLib.nsh"
!include "MUI2.nsh"
!include "winMessages.nsh"
!include "nsDialogs.nsh"

OutFile "test.exe"

Section
SectionEnd

Var dialog
Var hwnd
Var null

Var hwnd_listbox
Var hwnd_bitmap
Var res_bmp

Page Custom customPage
Function customPage
nsDialogs::Create 1018
Pop $dialog

/* Unpack bitmap files in advance */
InitPluginsDir
SetOutPath "$PluginsDir"
File "a.bmp"
File "b.bmp"

${NSD_CreateBitmap} 25% 0 190 171 ""
Pop $hwnd_bitmap
${NSD_SetImage} $hwnd_bitmap "$PluginsDir\a.bmp" $res_bmp
nsDialogs::SetUserData $hwnd_bitmap "a.bmp"
${NSD_OnClick} $hwnd_bitmap custompage.bitmap.onclick


nsDialogs::Show
${NSD_FreeImage} $res_bmp
FunctionEnd

Function custompage.bitmap.onclick
Pop $hwnd

/* Get control's rect on screen */
System::Call "*(i, i, i, i) i .r1"
System::Call "User32::GetWindowRect(i, i) i ($hwnd, r1) .r2"
System::Call "*$1(i, i, i, i) i (.r2, .r3, .r4, .r5)"

/* Get mouse cursor's position on screen */
System::Call "*(l, l) i .r6"
System::Call "User32::GetCursorPos(i) i (r6) .r7"
System::Call "*$6(i, i) i (.r7, .r8)"

/* Derive mouse cursor position relative to control */
IntOp $0 $7 - $2
IntOp $1 $8 - $3

/* Do something with that cursor position information here, perhaps */
/* MessageBox MB_OK "Cursor position relative to control: $0x$1" */

nsDialogs::GetUserData $hwnd_bitmap "a.bmp"
Pop $0

${Select} $0
${Case} "a.bmp"
StrCpy $1 "b.bmp"
${Default}
StrCpy $1 "a.bmp"
${EndSelect}

${NSD_FreeImage} $res_bmp
${NSD_SetImage} $hwnd_bitmap "$PluginsDir\$1" $res_bmp
nsDialogs::SetUserData $hwnd_bitmap "$1"
FunctionEnd

!insertmacro MUI_LANGUAGE "English"

You might want to have a look at the SkinCrafter plugin:
http://www.skincrafter.com/products/nsis-plugin

Never used it, but it looks like it might do what you want. (You probably have to create your own skin)


Excellent piece of code by Animather to demonstrate owner drawn buttons in NSIS .
But for now I 'm going to stick with Skincrafter plugin as it reduces much coding work for me.Also I saw a 60 % increase in the size of the installer by including this plugin. Can anything be done about this ?