Commit 5208fd11 authored by Eric Williams's avatar Eric Williams Committed by Alexandre Julliard

Minor fixups and tweaking, and a dummy hook.

parent 4dc58610
......@@ -11,7 +11,7 @@ originally produced by Borland Resource Workshop, and then heavily edited
#include <windows.h>
#include "cmdlgtst.h"
TestCommdlgMenu MENU
CmdlgtstMenu MENU
{
POPUP "&File"
{
......@@ -172,19 +172,6 @@ FONT 8, "MS Sans Serif"
CHECKBOX "PD_USEDEVMODECOPIES", I_PD_USEDEVMODECOPIES, 12, 264, 144, 12, BS_AUTOCHECKBOX | WS_TABSTOP
}
AboutDialog DIALOG 6, 15, 194, 119
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", IDOK, 72, 96, 50, 14
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
ICON "AboutIcon", -1, 84, 12, 18, 20
}
AboutIcon ICON
{
'00 00 01 00 01 00 20 20 10 00 00 00 00 00 E8 02'
......@@ -237,23 +224,6 @@ AboutIcon ICON
'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
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Open File/Save File Flags"
......@@ -280,3 +250,31 @@ FONT 8, "MS Sans Serif"
CHECKBOX "OFN_SHAREAWARE", I_OFN_SHAREAWARE, 12, 192, 132, 12, BS_AUTOCHECKBOX | WS_TABSTOP
CHECKBOX "OFN_SHOWHELP", I_OFN_SHOWHELP, 12, 204, 132, 12, BS_AUTOCHECKBOX | WS_TABSTOP
}
AboutDialog DIALOG 6, 15, 194, 119
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", IDOK, 72, 96, 50, 14
LTEXT "Common Dialog Test Jig Exerciser, version 1.20", -1, 13, 36, 168, 12
LTEXT "(c) 1999-2000, 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
}
UsageDialog DIALOG 183, 22, 190, 300
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Usage"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", IDOK, 70, 276, 50, 14
LTEXT "Common Dialog Test Jig Exerciser, version 1.20", -1, 13, 48, 168, 12
LTEXT "This tool tests COMMDLG for Wine.", -1, 12, 72, 168, 12
LTEXT "Flags are specified in the Flags menu.", -1, 12, 96, 168, 12
LTEXT "Color dialog changes background color.", -1, 12, 120, 168, 12
LTEXT "Font dialog changes all fonts, and font color if CF_EFFECTS is selected.", -1, 12, 144, 168, 24
LTEXT "Upper left hand corner indicate full pathname and title of the last successful Open or Save.", -1, 12, 180, 168, 24
LTEXT "(c) 1999-2000, Eric Williams. Rights are as granted under the WINE license. Don't hoard code...share it!", -1, 12, 228, 168, 36
ICON "AboutIcon", -1, 86, 12, 18, 20
CONTROL "", -1, "static", SS_BLACKRECT | WS_CHILD | WS_VISIBLE, 12, 216, 168, 2
}
// (c) 1999 Eric Williams. Rights as specified under the WINE
// (c) 1999-2000 Eric Williams. Rights as specified under the WINE
// License. Don't hoard code; share it!
//
// One might call this a Commdlg test jig. Its sole function in life
// is to call the Commdlg Common Dialogs; at present it doesn't even
// do anything horribly interesting with the results.
// is to call the Commdlg Common Dialogs. The results of a call to
// File Open or File Save are printed in the upper left corner;
// Font adjusts the font of the printout, and Color adjusts the color
// of the background.
// Ideally it would also do event logging and be a bit less stupid
// about displaying the results of the various requesters. But hey,
......@@ -13,6 +15,7 @@
#include <windows.h>
#include <commdlg.h>
#include <stdio.h>
#include <string.h>
#include "cmdlgtst.h"
// This structure is to set up flag / control associations for the custom
......@@ -31,20 +34,12 @@ struct FlagTableEntry {
unsigned long ft_bit;
};
// #ifdef __WINE_WINDOWS_H
// #define EXPORT
// #define HWND HWND32
// int ctx_debug = 0;
// #else
// #define EXPORT _export
// #endif
//#define FAR
#define EXPORT
static char menuName[] = "TestCommdlgMenu";
static char className[] = "TestCommdlg";
static char windowName[] = "TestCommdlg Window";
static char menuName[] = "CmdlgtstMenu";
static char className[] = "CmdlgtstClass";
static char windowName[] = "Cmdlgtst Window";
// global hInstance variable. This makes the code non-threadable,
// but wotthehell; this is Win32 anyway! (Though it does work
......@@ -62,6 +57,7 @@ static LOGFONT cf_lf;
static CHOOSEFONT cf;
static char ofn_filepat[] = "All Files (*.*)\0*.*\0Only Text Files (*.txt)\0*.txt\0";
static char ofn_result[1024];
static char ofn_titleresult[128];
static OPENFILENAME ofn;
// Stuff for find and replace. These are modeless, so I have to put them here.
......@@ -77,19 +73,33 @@ 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);
static COLORREF bgColor = RGB(255, 255, 255); // COLOR dialog
static COLORREF txtColor = RGB(0, 0, 0); // settable if one enables CF_EFFECTS
// Utility routines. Currently there is only one, and it's a nasty
// reminder that I'm not done yet.
// Utility routines.
void nyi(HWND hWnd)
{
// "Hi there! I'm not yet implemented!"
MessageBox(hWnd, "Not yet implemented!", "NYI", MB_ICONEXCLAMATION | MB_OK);
}
UINT CALLBACK dummyfnHook(HWND hWnd, UINT msg, UINT wParam, UINT lParam)
{
// If the user specifies something that needs an awfully stupid hook function,
// this is the one to use. It's a no-op, and says "I didn't do anything."
(void) hWnd;
(void) msg;
(void) wParam;
(void) lParam;
printf("dummyfnhook\n"); // visible under Wine, but Windows probably won't see it!
// Initial initialization code. This code simply shoves in predefined
return 0;
}
// Initialization code. This code simply shoves in predefined
// data into the COMMDLG data structures; in the future, I might use
// a series of loadable resources, or static initializers; of course,
// if Microsoft decides to change the field ordering, I'd be screwed.
......@@ -104,7 +114,7 @@ void mwi_Print(HWND hWnd)
pd.Flags = 0;
pd.nMinPage = 1;
pd.nMaxPage = 100;
pd.hInstance = 0;
pd.hInstance = g_hInstance;
pd.lCustData = 0;
pd.lpfnPrintHook = 0;
pd.lpfnSetupHook = 0;
......@@ -112,7 +122,6 @@ void mwi_Print(HWND hWnd)
pd.lpSetupTemplateName = 0;
pd.hPrintTemplate = 0;
pd.hSetupTemplate = 0;
}
void mwi_Color(HWND hWnd)
......@@ -126,7 +135,7 @@ void mwi_Color(HWND hWnd)
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hWnd;
cc.hInstance = 0;
cc.hInstance = g_hInstance;
cc.rgbResult = RGB(0,0,0);
cc.lpCustColors = cc_cr;
cc.Flags = 0;
......@@ -141,31 +150,33 @@ void mwi_Font(HWND hWnd)
cf.hwndOwner = hWnd;
cf.hDC = 0;
cf.lpLogFont = &cf_lf;
cf.Flags = 0;
cf.Flags = CF_SCREENFONTS; // something's needed for display; otherwise it craps out with an error
cf.rgbColors = RGB(0,0,0); // what is *this* doing here??
cf.lCustData = 0;
cf.lpfnHook = 0;
cf.lpTemplateName = 0;
cf.hInstance = 0;
cf.hInstance = g_hInstance;
cf.lpszStyle = 0;
cf.nFontType = 0;
cf.nSizeMin = 8;
cf.nSizeMax = 72;
cf_lf.lfHeight = -18; // this can be positive or negative, but negative is usually used.
}
void mwi_File(HWND hWnd)
{
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hInstance = 0;
ofn.hInstance = g_hInstance;
ofn.lpstrFilter = (LPSTR) ofn_filepat;
ofn.lpstrCustomFilter = 0;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = ofn_result;
ofn.nMaxFile = sizeof(ofn_result);
ofn.lpstrFileTitle = 0;
ofn.nMaxFileTitle = 0;
ofn.lpstrFileTitle = ofn_titleresult;
ofn.nMaxFileTitle = sizeof(ofn_titleresult);
ofn.lpstrInitialDir = 0;
ofn.lpstrTitle = "Open File";
ofn.Flags = 0;
......@@ -183,7 +194,7 @@ void mwi_FindReplace(HWND hWnd)
{
frS.lStructSize = sizeof(FINDREPLACE);
frS.hwndOwner = hWnd;
frS.hInstance = 0;
frS.hInstance = g_hInstance;
frS.Flags = FR_DOWN;
frS.lpstrFindWhat = fromstring;
frS.lpstrReplaceWith = tostring;
......@@ -222,6 +233,10 @@ void paintMainWindow(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
HFONT font;
HBRUSH brush;
(void) iMessage;
(void) wParam;
(void) lParam;
// Commence painting!
BeginPaint(hWnd, &ps);
......@@ -231,8 +246,11 @@ void paintMainWindow(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
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);
// Ideally, we'd only need to draw the exposed bit.
// But something in BeginPaint is screwing up the rectangle.
// Either that, or Windows is drawing it wrong. AARGH!
// Rectangle(ps.hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
Rectangle(ps.hdc, rect.left, rect.top, rect.right, rect.bottom);
// now draw a couple of lines, just for giggles.
......@@ -248,7 +266,8 @@ void paintMainWindow(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
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));
TextOut(ps.hdc, rect.left+10, rect.top+10, ofn_result, strlen(ofn_result));
TextOut(ps.hdc, rect.left+10, rect.top-cf_lf.lfHeight+10, ofn_titleresult, strlen(ofn_titleresult));
// set the HDC back to the old pen and brush,
// and delete the newly created objects.
......@@ -419,6 +438,8 @@ unsigned long mwcd_GetFlags(HWND hWnd, struct FlagTableEntry * table)
BOOL mwcd_Setup(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
struct FlagTableEntry * table, unsigned long * flags)
{
(void) lParam;
switch(uMsg)
{
case WM_INITDIALOG:
......@@ -586,6 +607,9 @@ BOOL CALLBACK mwcd_FileSetup(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
BOOL CALLBACK mwcd_About(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
(void) wParam;
(void) lParam;
switch(uMsg) {
case WM_INITDIALOG: return TRUE; // let WINDOWS set the focus.
case WM_COMMAND: EndDialog(hWnd, 0); return TRUE; // it's our OK button.
......@@ -806,9 +830,11 @@ HWND createMainWindow(HINSTANCE hInstance, int show)
int messageLoop(HINSTANCE hInstance, HWND hWnd)
{
MSG msg;
(void) hInstance;
(void) hWnd;
while(GetMessage(&msg, 0, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
......@@ -831,6 +857,8 @@ int PASCAL WinMain(
{
HWND hWnd;
(void) lpszCmdLine;
strcpy(ofn_result, "--- not yet set ---");
if(hPrevInstance==0) {
......@@ -844,12 +872,11 @@ int PASCAL WinMain(
if(hWnd == 0)
return -1;
return messageLoop(hInstance, hWnd);
}
// And now the end of the program. Enjoy.
// (c) 1999 Eric Williams. Rights as specified under the WINE
// (c) 1999-2000 Eric Williams. Rights as specified under the WINE
// License. Don't hoard code; share it!
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment