- color and font dialogs now actually do something interesting,
and force a redraw when successful. Background color is adjustable. Text color is also adjustable, but the user has to set the CF_EFFECTS flag first. - text is output left-right centered, baseline, at the middle of the window, and moves with the window. Text font is adjustable. - Success and failure MessageBox calls for Color, Font, Open, and Save have been removed or suppressed. They annoyed me after awhile, and I suspect they annoyed others, too. Use my tool! :-) - cmdlgtst now has the full pathname in the upper left corner; which may assist in debugging certain problems -- or it may not. :-) - usage dialog added
This commit is contained in:
parent
43b667ceb7
commit
5d2a658865
|
@ -18,6 +18,7 @@
|
||||||
#define I_OFN_ENABLETEMPLATE 104
|
#define I_OFN_ENABLETEMPLATE 104
|
||||||
#define I_OFN_ENABLEHOOK 103
|
#define I_OFN_ENABLEHOOK 103
|
||||||
#define I_OFN_CREATEPROMPT 102
|
#define I_OFN_CREATEPROMPT 102
|
||||||
|
#define CM_H_USAGE 106
|
||||||
#define CM_H_ABOUT 103
|
#define CM_H_ABOUT 103
|
||||||
#define CM_F_FILE 102
|
#define CM_F_FILE 102
|
||||||
#define I_PD_SHOWHELP 121
|
#define I_PD_SHOWHELP 121
|
||||||
|
|
|
@ -46,6 +46,7 @@ TestCommdlgMenu MENU
|
||||||
|
|
||||||
POPUP "&Help"
|
POPUP "&Help"
|
||||||
{
|
{
|
||||||
|
MENUITEM "&Usage", CM_H_USAGE
|
||||||
MENUITEM "&About", CM_H_ABOUT
|
MENUITEM "&About", CM_H_ABOUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +179,7 @@ CAPTION "About"
|
||||||
FONT 8, "MS Sans Serif"
|
FONT 8, "MS Sans Serif"
|
||||||
{
|
{
|
||||||
DEFPUSHBUTTON "OK", IDOK, 72, 96, 50, 14
|
DEFPUSHBUTTON "OK", IDOK, 72, 96, 50, 14
|
||||||
LTEXT "Common Dialog Test Jig Exerciser, version 1.00", -1, 13, 36, 168, 12
|
LTEXT "Common Dialog Test Jig Exerciser, version 1.10", -1, 13, 36, 168, 12
|
||||||
LTEXT "(c) 1999, Eric Williams. Rights are as granted under the WINE license. Don't hoard code...share it!", -1, 18, 60, 157, 24
|
LTEXT "(c) 1999, Eric Williams. Rights are as granted under the WINE license. Don't hoard code...share it!", -1, 18, 60, 157, 24
|
||||||
ICON "AboutIcon", -1, 84, 12, 18, 20
|
ICON "AboutIcon", -1, 84, 12, 18, 20
|
||||||
}
|
}
|
||||||
|
@ -236,6 +237,23 @@ AboutIcon ICON
|
||||||
'00 00 00 00 00 00 00 00 00 00 00 00 00 00'
|
'00 00 00 00 00 00 00 00 00 00 00 00 00 00'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UsageDialog DIALOG 6, 15, 194, 169
|
||||||
|
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "Usage"
|
||||||
|
FONT 8, "MS Sans Serif"
|
||||||
|
{
|
||||||
|
DEFPUSHBUTTON "OK", IDOK, 72, 146, 50, 14
|
||||||
|
LTEXT "Common Dialog Test Jig Exerciser, version 1.10", -1, 13, 36, 168, 12
|
||||||
|
LTEXT "The Commdlg menu allows for testing of the COMMDLG.", -1, 13, 48, 168, 12
|
||||||
|
LTEXT "The Flags menu allows for setting flags of the COMMDLG.", -1, 13, 60, 168, 12
|
||||||
|
LTEXT "Color dialog changes background color.", -1, 13, 72, 168, 12
|
||||||
|
LTEXT "Font dialog changes all fonts.", -1, 13, 72, 168, 12
|
||||||
|
LTEXT "Upper left hand corner contains the current contents of.", -1, 13, 84, 168, 12
|
||||||
|
LTEXT "the last successful OPEN or SAVE.", -1, 13, 92, 168, 12
|
||||||
|
LTEXT "(c) 1999, Eric Williams. Rights are as granted under the WINE license. Don't hoard code...share it!", -1, 18, 110, 157, 24
|
||||||
|
ICON "AboutIcon", -1, 84, 12, 18, 20
|
||||||
|
}
|
||||||
|
|
||||||
File_Flags_Dialog DIALOG 6, 15, 207, 227
|
File_Flags_Dialog DIALOG 6, 15, 207, 227
|
||||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "Open File/Save File Flags"
|
CAPTION "Open File/Save File Flags"
|
||||||
|
|
|
@ -69,9 +69,17 @@ static OPENFILENAME ofn;
|
||||||
static HWND findDialogBox = 0;
|
static HWND findDialogBox = 0;
|
||||||
static UINT findMessageId = 0;
|
static UINT findMessageId = 0;
|
||||||
|
|
||||||
|
static int findDialogBoxInit = 0;
|
||||||
|
static int findDialogStructInit = 0;
|
||||||
static FINDREPLACE frS;
|
static FINDREPLACE frS;
|
||||||
static char fromstring[1024], tostring[1024];
|
static char fromstring[1024], tostring[1024];
|
||||||
|
|
||||||
|
// Stuff for the drawing of the window(s). I put them here for convenience.
|
||||||
|
|
||||||
|
static COLORREF fgColor = RGB(0, 0, 0); // not settable
|
||||||
|
static COLORREF bgColor = RGB(255, 255, 255);
|
||||||
|
static COLORREF txtColor = RGB(0, 0, 0);
|
||||||
|
|
||||||
// Utility routines. Currently there is only one, and it's a nasty
|
// Utility routines. Currently there is only one, and it's a nasty
|
||||||
// reminder that I'm not done yet.
|
// reminder that I'm not done yet.
|
||||||
|
|
||||||
|
@ -210,17 +218,48 @@ void paintMainWindow(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
HPEN pen;
|
||||||
|
HFONT font;
|
||||||
|
HBRUSH brush;
|
||||||
|
|
||||||
// This is the Windows equivalent of one of my widgets,
|
// Commence painting!
|
||||||
// which basically just draws a large 'X'.
|
|
||||||
|
|
||||||
BeginPaint(hWnd, &ps);
|
BeginPaint(hWnd, &ps);
|
||||||
GetClientRect(hWnd, (LPRECT) &rect);
|
GetClientRect(hWnd, (LPRECT) &rect);
|
||||||
|
|
||||||
|
pen = (HPEN) SelectObject(ps.hdc, CreatePen(0, 0, fgColor));
|
||||||
|
brush = (HBRUSH) SelectObject(ps.hdc, CreateSolidBrush(bgColor));
|
||||||
|
font = (HFONT) SelectObject(ps.hdc, CreateFontIndirect(&cf_lf));
|
||||||
|
|
||||||
|
// only need to draw the exposed bit.
|
||||||
|
Rectangle(ps.hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
|
||||||
|
|
||||||
|
// now draw a couple of lines, just for giggles.
|
||||||
|
|
||||||
MoveToEx(ps.hdc, rect.left, rect.top, (POINT FAR *) 0);
|
MoveToEx(ps.hdc, rect.left, rect.top, (POINT FAR *) 0);
|
||||||
LineTo(ps.hdc, rect.right, rect.bottom);
|
LineTo(ps.hdc, rect.right, rect.bottom);
|
||||||
MoveToEx(ps.hdc, rect.left, rect.bottom, (POINT FAR *) 0);
|
MoveToEx(ps.hdc, rect.left, rect.bottom, (POINT FAR *) 0);
|
||||||
LineTo(ps.hdc, rect.right, rect.top);
|
LineTo(ps.hdc, rect.right, rect.top);
|
||||||
|
|
||||||
|
// draw some text
|
||||||
|
|
||||||
|
SetTextAlign(ps.hdc, TA_CENTER|TA_BASELINE);
|
||||||
|
SetTextColor(ps.hdc, txtColor);
|
||||||
|
TextOut(ps.hdc, (rect.left+rect.right)/2, (rect.top+rect.bottom)/2, "Common Dialog Test Page", 23);
|
||||||
|
|
||||||
|
SetTextAlign(ps.hdc, TA_LEFT|TA_TOP);
|
||||||
|
TextOut(ps.hdc, rect.left, rect.top, ofn_result, strlen(ofn_result));
|
||||||
|
|
||||||
|
// set the HDC back to the old pen and brush,
|
||||||
|
// and delete the newly created objects.
|
||||||
|
|
||||||
|
pen = (HPEN) SelectObject(ps.hdc, pen);
|
||||||
|
DeleteObject(pen);
|
||||||
|
brush = (HBRUSH) SelectObject(ps.hdc, brush);
|
||||||
|
DeleteObject(brush);
|
||||||
|
font = (HFONT) SelectObject(ps.hdc, font);
|
||||||
|
DeleteObject(font);
|
||||||
|
|
||||||
EndPaint(hWnd, &ps);
|
EndPaint(hWnd, &ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +268,7 @@ void paintMainWindow(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
|
||||||
// the CDERR_xxx return values into something resembling usable text;
|
// the CDERR_xxx return values into something resembling usable text;
|
||||||
// consult cderr.h to see what was returned.
|
// consult cderr.h to see what was returned.
|
||||||
|
|
||||||
void mw_checkError(HWND hWnd)
|
void mw_checkError(HWND hWnd, BOOL explicitcancel)
|
||||||
{
|
{
|
||||||
DWORD errval = CommDlgExtendedError();
|
DWORD errval = CommDlgExtendedError();
|
||||||
if(errval) {
|
if(errval) {
|
||||||
|
@ -239,7 +278,7 @@ void mw_checkError(HWND hWnd)
|
||||||
MessageBox(hWnd, errbuf, "Error", MB_ICONEXCLAMATION | MB_OK);
|
MessageBox(hWnd, errbuf, "Error", MB_ICONEXCLAMATION | MB_OK);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MessageBox(hWnd, "Nope, user canceled it.", "No", MB_OK);
|
if(explicitcancel) MessageBox(hWnd, "Nope, user canceled it.", "No", MB_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,24 +290,31 @@ void mw_checkError(HWND hWnd)
|
||||||
void mw_ColorSetup(HWND hWnd)
|
void mw_ColorSetup(HWND hWnd)
|
||||||
{
|
{
|
||||||
if(ChooseColor(&cc)) {
|
if(ChooseColor(&cc)) {
|
||||||
MessageBox(hWnd, "Success.", "Yes", MB_OK);
|
RECT rect;
|
||||||
|
|
||||||
|
GetClientRect(hWnd, (LPRECT) &rect);
|
||||||
|
InvalidateRect(hWnd, (LPRECT) &rect, FALSE);
|
||||||
|
bgColor = cc.rgbResult;
|
||||||
}
|
}
|
||||||
else mw_checkError(hWnd);
|
else mw_checkError(hWnd, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mw_FontSetup(HWND hWnd)
|
void mw_FontSetup(HWND hWnd)
|
||||||
{
|
{
|
||||||
if(ChooseFont(&cf)) {
|
if(ChooseFont(&cf)) {
|
||||||
MessageBox(hWnd, "Success.", "Yes", MB_OK);
|
RECT rect;
|
||||||
|
GetClientRect(hWnd, (LPRECT) &rect);
|
||||||
|
InvalidateRect(hWnd, (LPRECT) &rect, FALSE);
|
||||||
|
txtColor = cf.rgbColors;
|
||||||
}
|
}
|
||||||
else mw_checkError(hWnd);
|
else mw_checkError(hWnd, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mw_FindSetup(HWND hWnd)
|
void mw_FindSetup(HWND hWnd)
|
||||||
{
|
{
|
||||||
if(findDialogBox == 0) {
|
if(findDialogBox == 0) {
|
||||||
findDialogBox = FindText(&frS);
|
findDialogBox = FindText(&frS);
|
||||||
if(findDialogBox==0) mw_checkError(hWnd);
|
if(findDialogBox==0) mw_checkError(hWnd,TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,24 +322,28 @@ void mw_ReplaceSetup(HWND hWnd)
|
||||||
{
|
{
|
||||||
if(findDialogBox == 0) {
|
if(findDialogBox == 0) {
|
||||||
findDialogBox = ReplaceText(&frS);
|
findDialogBox = ReplaceText(&frS);
|
||||||
if(findDialogBox==0) mw_checkError(hWnd);
|
if(findDialogBox==0) mw_checkError(hWnd,TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mw_OpenSetup(HWND hWnd)
|
void mw_OpenSetup(HWND hWnd)
|
||||||
{
|
{
|
||||||
if(GetOpenFileName(&ofn)) {
|
if(GetOpenFileName(&ofn)) {
|
||||||
MessageBox(hWnd, "Success.", "Yes", MB_OK);
|
RECT rect;
|
||||||
|
GetClientRect(hWnd, (LPRECT) &rect);
|
||||||
|
InvalidateRect(hWnd, (LPRECT) &rect, FALSE);
|
||||||
}
|
}
|
||||||
else mw_checkError(hWnd);
|
else mw_checkError(hWnd,FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mw_SaveSetup(HWND hWnd)
|
void mw_SaveSetup(HWND hWnd)
|
||||||
{
|
{
|
||||||
if(GetSaveFileName(&ofn)) {
|
if(GetSaveFileName(&ofn)) {
|
||||||
MessageBox(hWnd, "Success.", "Yes", MB_OK);
|
RECT rect;
|
||||||
|
GetClientRect(hWnd, (LPRECT) &rect);
|
||||||
|
InvalidateRect(hWnd, (LPRECT) &rect, FALSE);
|
||||||
}
|
}
|
||||||
else mw_checkError(hWnd);
|
else mw_checkError(hWnd,FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't find documentation in Borland for this one. Does it
|
// Can't find documentation in Borland for this one. Does it
|
||||||
|
@ -321,9 +371,9 @@ void mw_PrintSetup(HWND hWnd)
|
||||||
// Escape(tmp.hDC, NEWFRAME, 0, NULL, NULL);
|
// Escape(tmp.hDC, NEWFRAME, 0, NULL, NULL);
|
||||||
// Escape(tmp.hDC, ENDDOC, 0, NULL, NULL);
|
// Escape(tmp.hDC, ENDDOC, 0, NULL, NULL);
|
||||||
// DeleteDC(tmp.hDC);
|
// DeleteDC(tmp.hDC);
|
||||||
if (pd.hDevMode)
|
if (pd.hDevMode != NULL)
|
||||||
GlobalFree(pd.hDevMode);
|
GlobalFree(pd.hDevMode);
|
||||||
if (pd.hDevNames)
|
if (pd.hDevNames != NULL)
|
||||||
GlobalFree(pd.hDevNames);
|
GlobalFree(pd.hDevNames);
|
||||||
|
|
||||||
pd.hDevMode = 0;
|
pd.hDevMode = 0;
|
||||||
|
@ -331,7 +381,7 @@ void mw_PrintSetup(HWND hWnd)
|
||||||
|
|
||||||
MessageBox(hWnd, "Success.", "Yes", MB_OK);
|
MessageBox(hWnd, "Success.", "Yes", MB_OK);
|
||||||
}
|
}
|
||||||
else mw_checkError(hWnd);
|
else mw_checkError(hWnd,TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some support functions for the custom dialog box handlers.
|
// Some support functions for the custom dialog box handlers.
|
||||||
|
@ -685,6 +735,8 @@ LRESULT CALLBACK EXPORT mainWindowDispatcher(
|
||||||
|
|
||||||
case CM_H_ABOUT:
|
case CM_H_ABOUT:
|
||||||
DialogBox(g_hInstance, "AboutDialog", hWnd, (DLGPROC) mwcd_About);
|
DialogBox(g_hInstance, "AboutDialog", hWnd, (DLGPROC) mwcd_About);
|
||||||
|
case CM_H_USAGE:
|
||||||
|
DialogBox(g_hInstance, "UsageDialog", hWnd, (DLGPROC) mwcd_About);
|
||||||
// return value? *What* return value?
|
// return value? *What* return value?
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -778,6 +830,8 @@ int PASCAL WinMain(
|
||||||
{
|
{
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
|
|
||||||
|
strcpy(ofn_result, "--- not yet set ---");
|
||||||
|
|
||||||
if(hPrevInstance==0) {
|
if(hPrevInstance==0) {
|
||||||
if(!registerMainWindowClass(hInstance))
|
if(!registerMainWindowClass(hInstance))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue