I want to change the color of the outer dialog window in NSIS. I have created pages using NSDialogs.
I recently change the size of this using
System::Call 'user32::SetWindowPos(i$hwndparent,i,i,i,i 629,i 400,i 0x16)'
IS there similar way of changing the border/title bar color of this outer dialog windows?
You can change the inner and outer dialogs with SetCtlColors:
Function myPageCreate
nsDialogs::Create 1018
Pop $0
SetCtlColors $hwndparent 000000 ccff00
SetCtlColors $0 000000 ff00cc
nsDialogs::Show
FunctionEnd
To change the non-client areas like titlebar and borders you need to use a 3rd-party plugin. I personally don't think this is a good idea but you can probably find several different NSIS skinning plugins if you want to force such things on your users...
Related
So for the simple feat of wanting to put an icon on the right side of button text instead of the left resulted in having to use owner draw buttons (but someone here said Custom Draw is actually available if using visual themes). Okay, fine, but now I'm finding you can't really duplicate what Windows standard buttons do when it's not in owner draw mode.
For a normal enabled button I can get the look correct by checking if visual styles are available or not and then using either the DrawThemeBackground() / DrawThemeText() or DrawFrameControl() / DrawText(). However the hot key underline character is shown even when alt key is not pressed, the default buttons don't show it until alt pressed.
For a disabled button, I can't duplicate the disabled look of the icon placed on the button. I tried DrawState() over DrawIconEx() but that looks like the old Windows 3.1 type grey graphic not the visual style dimmed graphic. I see there is a DrawThemeIcon() for an image list, I guess I could try that (I'd have to test non visual style mode to see if DrawState() matches when not using visual styles).
Also, as you hover over the button, the state doesn't change, I understand that if using owner draw, that doesn't occur, maybe it would still work with Custom Draw?
So the two main questions are:
1 - Is there something built-in to the button / owner draw to handle the underlined hotkey only when alt was pressed?
Update to Question 1: I found DT_HIDEPREFIX in DrawText() and using Custom Draw there is the CDIS_SHOWKEYBOARDCUES flag. However with Owner Draw I'm not sure if there is a flag someplace?
2 - How do you draw an icon for a button that is disabled to match what default buttons do?
TIA!!
For shortcut underline you can use WM_QUERYUISTATE to ask if it should be hidden or visible
DWORD draw_text_flags = ...;
if ( SendMessage( control_hwnd, WM_QUERYUISTATE, 0, 0 ) & UISF_HIDEACCEL ) != 0 )
{
// hide prefix
draw_text_flags |= DT_HIDEPREFIX;
}
// some combination of PBS_DEFAULTED, PBS_DISABLED, PBS_HOT, PBS_NORMAL, PBS_PRESSED;
int state = ...;
DrawThemeText( theme, hdc, BP_PUSHBUTTON, state, text, text_len, draw_text_flags, 0, rect );
Answer to Q2: If you create an HIMAGELIST using ILC_COLOR32 | ILC_MASK, and use ILD_NORMAL|ILD_BLEND25 on ImageList_Draw() it gives the same look as windows default buttons for a disabled button.
Based on responses from #Remy-Lebeau and #Daniel-Sęk and reviewing various projects on CodeProject, I create an easy to use class to handle this. It can be found at CodeProject. Thanks Guys.
For the purpose of putting more actions on fewer buttons I was hoping to detect if a window has scrolling functions. For example when a pop-up is asking you if you want to save something or not it tends to default to No. That window does not have any functionality tied to the mouse wheel action. In that scope I was planning to have the mouse wheel up and down input up or down directions. Maybe there is a way to detect if the window has scrolling enabled? Or maybe there is another work-around such as that pop-up window having a specific windows class?
Look at the GetScrollBarInfo function in the answer here How I can check if a Window has visible scrollbars using his HWND? for some useful info, but in my view, easiest is to capture window classes and fire mouse wheels accordingly, just like the example in the help for #if except you will need a correct WinTitle (use class of pop up) instead of identifying the Taskbar, and you will send tab and alt+tab in your mousewheels instead of the volume controls:
#If MouseIsOver("ahk_class Shell_TrayWnd")
WheelUp::Send {Volume_Up}
WheelDown::Send {Volume_Down}
MouseIsOver(WinTitle) {
MouseGetPos,,, Win
return WinExist(WinTitle . " ahk_id " . Win)
}
https://www.autohotkey.com/docs/commands/_If.htm
Hth,
I am creating a dialog with a tab control. Each tab should show different set of controls, so I have created child dialog boxes in resource editor to behave like pages.
I have used instructions from this post to do this.
In resource editor I made dialog boxes without border, set their styles to Child, removed system menu, and I have set flags Control and Control Parent to true.
In my child dialog box procedures I have handled WM_INITDIALOG by adding EnableThemeDialgTexture(handleOfmyDialog, ETDT_ENABLETAB); and returning TRUE. No WM_ERASEBKGND, WM_PAINT or WM_CTLCOLORDLG have been overridden.
In main dialog box that contains tab control, I have created "child dialogs" with CreateDialog function, and have used MoveWindow to properly position them.
I did not use EndDialog to destroy "child dialogs" on IDCANCEL or WM_CLOSE, I think that they will get destroyed automatically.
I have used Visual Studio 2013 on Windows 8.1 to do all this.
There seems to be no problem on Windows 7 and Windows 8.1, but maybe my eyes are playing tricks with me, since the background color of the tab control is similar to the default background color of the dialog box. The problem is best seen on Windows XP, as shown on the picture below:
How can I make background color of "child dialogs" ( and their child controls like checkbox/trackbar/radio button/static control ) to be transparent ( match the background color of tab control )?
Thank you.
This is a pretty straight-forward problem. You can't see the mistake on later Windows version because they no longer use a gradient for the "texture". EnableThemeDialogTexture() worked just fine, your dialog certainly has the same texture as your tabcontrol. The brush origin starts at the upper-left corner of the dialog. Like it does for the tabcontrol. But the dialog is not positioned correctly, now the gradients are mis-aligned and the dialog no longer blends.
You need to move the dialog so it is located correctly inside the tab page area. The relevant line of code from the MSDN article:
// Size the dialog box.
SetWindowPos(hwndDlg, NULL,
0, 0, // <=== here!
rcTab.right + cyMargin + (2 * GetSystemMetrics(SM_CXDLGFRAME)),
rcTab.bottom + rcButton.bottom + (2 * cyMargin)
+ (2 * GetSystemMetrics(SM_CYDLGFRAME))
+ GetSystemMetrics(SM_CYCAPTION),
SWP_NOMOVE | SWP_NOZORDER);
Positioned at (0, 0) in the client area of the tabcontrol, now the gradients align.
Hans’ observation is right, but with the wrong conclusions.
Indeed, EnableThemeDialogTexture() worked: There clearly is a gradient on the background of the Slider control. And indeed it does not line up with the tab control’s background.
However, this is not an alignment problem. The gradient you see on the Slider control is the correct gradient according to EnableThemeDialogTexture(). The gradient on the background is actually the wrong one. You can clearly see it with enhanced contrast – the background gradient is blocky and coarse, while the Slider’s gradient is perfectly fine.
I observed this exact behavior when the main window had the WS_CLIPCHILDREN style set while the Z order was wrong (tab above child). Move the child dialog boxes to the top of the Z order via SetWindowPos(child, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE) and it should align perfectly and not be blocky any more.
How can I obtain the window "id" - unique number associated with a Win32 window?
Can I obtain the id within a NSIS script(.nsi file)? If not what outside program can I use? ResHacker is not showing me the correct dialogs when I run my installer for some reason. I've heard of GDISpy or something with a name similar to that.
What I am trying to do is change the z index of some windows within a MUI2 pages and to set checkboxes backgrounds to transparent within a custom page.
What your easiest method for finding out a windows unique id?
EDIT
Sorry I'm not familiar with the correct term is for what I am talking about. I am not talking about the HWND variable/handle I am talking about that windows unique window id thats an integer.
# In NSIS
GetDlgItem $R0 ${parentHWND} 1012 # the 1012 is what I am referring to as the window ID
The ids for a dialogs child controls can be found with a spy tool like Winspy++ (This tool displays it in hex so convert with calc.exe or prefix the number with 0x in the .nsi)
NSIS has two nested dialogs, the outer dialog hosts the next, back and cancel buttons. The inner dialog hosts the controls for the current page.
To get the handle to a button in the outer dialog:
GetDlgItem $1 $hwndparent 1
And for the inner dialog:
FindWindow $0 "#32770" "" $HWNDPARENT ;Find inner dialog first
GetDlgItem $1 $0 0x666
For a custom page, the id (and z-order) depends on the order you create the controls in...
In Perl Win32::GUI desktop apps,
While checkbox checked status I need to hide some controls and I need to move the controls to places which are hidden, for window compact view in Perl Win32::GUI. While using below code the control's images are repeated(duplicates) at the time of Controls movement. Kindly please give solution to avoid duplicate images of controls while moving and resizing the window.
sub Check_Status{
if($btwdates->GetCheck eq 1){
$Pushlistmodelabel->Move(30,168);
$Fromdatelabel->Show();
$get_From_day->Show();
$Todatelabel->Show();
$get_To_day->Show();
$FoldersOption->Disable();
$PushListButton->Move(200,255);
$processlabel->Move(2,285);
$PushListButton->Move(135,295);
$processlabel->Move(2,320);
$Selectionlabel->Move(195,168);
$FilesOption->Move(200,195);
$FoldersOption->Move(200,225);
$With_root->Move(35,195);
$Without_root->Move(35,225);
$changeOption->Move(35,255);
$replacepath->Move(180,255);
Win32::GUI::DoEvents() >= 0;
}
else{
$FoldersOption->Move(200,165);
$FilesOption->Move(200,135);
$FoldersOption->Enable();
$Selectionlabel->Move(195,108);
$Pushlistmodelabel->Move(30,108);
$Fromdatelabel->Hide();
$get_From_day->Hide();
$Todatelabel->Hide();
$get_To_day->Hide();
$PushListButton->Move(200,195);
$processlabel->Move(2,225);
$Pushlistmodelabel->Move(30,108);
$With_root->Move(35,135);
$Without_root->Move(35,165);
$changeOption->Move(35,195);
$replacepath->Move(180,195);
}
}
Taking a shot in the dark (I don't have a win32 perl install), you could try the SetRedraw method. SetRedraw(0) before rearranging the controls and SetRedraw(1) afterwards. Maybe also a manual Redraw() afterwards.
There is a non-perl-specific discussion of some techniques for avoiding flicker when updating a window in the question Win32 GUI flickering on resize.