|
-
March 5th, 2010, 07:23 PM
#1
Add button to OPENFILENAME dialog?
I'm trying to add my own button to the OPENFILENAME dialog as a template, and it seems to work,
however, there's two small problems.
The first problem is that the button is being clipped by the drag icon. My template has
the "Clip Children" and "Clip Siblings" flags set to TRUE, but that doesn't seem to be working.
I also tried using SetWindowPos() and HWND_TOP/HWND_TOPMOST flag, but that doesn't work either.
Another problem is that the button has a dark outline. Turning the "Tapstop" flag on/off has
no effect of getting rid of it. The button seems to be in its own grouping, it's not part of
the other buttons, so that might explain why. But, I would like to get rid of the outline.
Any ideas to fix this?
I was thinking of just using the default CDN_HELP button, and rename it to what I want,
(which would solve all of my problems), but I didn't know what ill-effects this would cause, if any.

Some code I use:
Code:
{
OPENFILENAME ofn;
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST |
OFN_EXPLORER | OFN_HIDEREADONLY |
OFN_ENABLEHOOK |
OFN_ENABLETEMPLATE |
OFN_SHOWHELP |
OFN_ENABLESIZING;
ofn.lpfnHook = (LPOFNHOOKPROC)OpenFileHookProc;
ofn.lpTemplateName = MAKEINTRESOURCE(IDD_MY_BUTTON_DIALOG);
ofn.hInstance = AfxGetResourceHandle();
}
BOOL CALLBACK
OpenFileHookProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_INITDIALOG:
return TRUE;
case WM_SIZE: {
HWND hButton = GetDlgItem( hDlg, IDB_PRESSME );
SetWindowPos( hButton, NULL, dw-bw-8*2+border, button_rect.top, 0,0, SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOOWNERZORDER);
}
break;
default:
break;
}
return FALSE;
}
-
March 7th, 2010, 02:33 AM
#2
Re: Add button to OPENFILENAME dialog?
Well, just let a little bit more space for your button to avoid being clipped by the drag icon.
The dark outline is most possible because the button has BS_DEFPUSHBUTTON style.
-
March 7th, 2010, 01:31 PM
#3
Re: Add button to OPENFILENAME dialog?
Thanks for reply.
 Originally Posted by ovidiucucu
Well, just let a little bit more space for your button to avoid being clipped by the drag icon.
The dark outline is most possible because the button has BS_DEFPUSHBUTTON style.
I can avoid clipping by adding more space at the bottom, but I noticed that the default "Help" button is
not clipped when it is exactly in the same position as my button. I was trying to duplicate this look.
Here's the button resource template. It's defined as a normal button:
Code:
IDD_MY_BUTTON_DIALOG DIALOGEX 0, 0, 50, 20
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
PUSHBUTTON "PressMe!",IDB_PRESSME,0,0,50,14,NOT WS_TABSTOP
END
I think there's some unwritten rule that says if there's only one button in a grouping, it automatically becomes
the default button, even if it's not defined as so. So, probably not possible.
Last edited by Syslock; March 7th, 2010 at 03:21 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|