"INSERT2", "MYMENU", "MYMENU2"に「ダイレクト・アニメーション」「テキスト」のメニュー項目を 追加しました。// hedll.rcの一部 ///////////////////////////////////////////////////////////////////////////// // // GIF // WHAT GIF DISCARDABLE "what.gif" MAIL GIF DISCARDABLE "mail.gif" HOME GIF DISCARDABLE "home.gif" INDEX GIF DISCARDABLE "index.gif" BACK GIF DISCARDABLE "back.gif" CONTENTS GIF DISCARDABLE "contents.gif" ///////////////////////////////////////////////////////////////////////////// // // Menu // INSERT2 MENU DISCARDABLE BEGIN POPUP "ダミーです" BEGIN MENUITEM "基本項目入力", IDM_BASICINPUT MENUITEM "JavaScriptの挿入", IDM_SCRIPT POPUP "タグの挿入" BEGIN MENUITEM "<P>", IDM_P MENUITEM "<BR>", IDM_BR MENUITEM "<H*></H*>...", IDM_H MENUITEM "<IMG>...", IDM_IMAGE MENUITEM "<A HREF></A>...", IDM_A MENUITEM "<TABLE></TABLE>...", IDM_TABLE MENUITEM "<FORM></FORM>...", IDM_FORM MENUITEM "<INPUT>...", IDM_INPUT END POPUP "GIF画像" BEGIN MENUITEM "What's New", IDM_WHAT MENUITEM "Mail", IDM_MAILTO MENUITEM "Home", IDM_HOME MENUITEM "Index", IDM_INDEX MENUITEM "Back", IDM_BACK MENUITEM "Contents", IDM_CONTENTS END MENUITEM SEPARATOR POPUP "ダイレクト・アニメーション" BEGIN MENUITEM "テキスト", IDM_DIRECTANI_TEXT END END END EDIT MENU DISCARDABLE BEGIN POPUP "ダミーです" BEGIN MENUITEM "コピー", IDM_COPY MENUITEM "切り取り", IDM_CUT MENUITEM "貼り付け", IDM_PASTE MENUITEM "削除", IDM_DELETE MENUITEM "元に戻す", IDM_UNDO END END FILE MENU DISCARDABLE BEGIN POPUP "ダミーです" BEGIN MENUITEM "新規作成", IDM_NEW MENUITEM "開く", IDM_OPEN MENUITEM "上書き保存", IDM_SAVE END END INSERT MENU DISCARDABLE BEGIN POPUP "ダミーです" BEGIN MENUITEM "<P>", IDM_P MENUITEM "<BR>", IDM_BR MENUITEM "<H*></H*>...", IDM_H MENUITEM "<IMG>...", IDM_IMAGE MENUITEM "<A HREF></A>...", IDM_A MENUITEM "<TABLE></TABLE>...", IDM_TABLE MENUITEM "<FORM></FORM>...", IDM_FORM MENUITEM "<INPUT>...", IDM_INPUT END END MYMENU MENU DISCARDABLE BEGIN POPUP "ファイル(&F)" BEGIN MENUITEM "新規作成(&N)...\tCtrl+N", IDM_NEW MENUITEM "開く(&O)...\tCtrl+O", IDM_OPEN MENUITEM SEPARATOR MENUITEM "上書き保存(&S)\tCtrl+S", IDM_SAVE MENUITEM "名前を付けて保存(&A)...", IDM_SAVEAS MENUITEM SEPARATOR MENUITEM "アプリケーションの終了(&X)", IDM_END END POPUP "編集(&E)" BEGIN MENUITEM "元に戻す(&U)\tCtrl+Z", IDM_UNDO MENUITEM "切り取り(&T)\tCtrl+X", IDM_CUT MENUITEM "コピー(&C)\tCtrl+C", IDM_COPY MENUITEM "貼り付け(&P)\tCtrl+V", IDM_PASTE MENUITEM "削除(&D)\tCtrl+D", IDM_DELETE MENUITEM SEPARATOR MENUITEM "すべて選択(&L)\tCtrl+A", IDM_ALL END POPUP "挿入(&I)" BEGIN MENUITEM "基本項目入力(&B)...\tShift+Ctrl+B", IDM_BASICINPUT MENUITEM SEPARATOR POPUP "タグの挿入" BEGIN MENUITEM "<P>", IDM_P MENUITEM "<BR>", IDM_BR MENUITEM "<H*></H*>...", IDM_H MENUITEM "<IMG>...", IDM_IMAGE MENUITEM "<A HREF></A>...", IDM_A MENUITEM "<TABLE></TABLE>...", IDM_TABLE MENUITEM "<FORM></FORM>...", IDM_FORM MENUITEM "<INPUT>...", IDM_INPUT END POPUP "JavaScriptの挿入" BEGIN MENUITEM "<SCRIPT>", IDM_SCRIPT END POPUP "GIF画像" BEGIN MENUITEM "What's New", IDM_WHAT MENUITEM "Mail", IDM_MAILTO MENUITEM "Home", IDM_HOME MENUITEM "Index", IDM_INDEX MENUITEM "Back", IDM_BACK MENUITEM "Contents", IDM_CONTENTS END MENUITEM SEPARATOR POPUP "ダイレクト・アニメーション" BEGIN MENUITEM "テキスト", IDM_DIRECTANI_TEXT END END POPUP "ブラウザ(&B)" BEGIN MENUITEM "ブラウザ起動(&E)\tF12", IDM_BROWSER END POPUP "オプション(&O)" BEGIN POPUP "ツールチップ(&T)" BEGIN MENUITEM "文字色(&L)", IDM_TIPTXTCOLOR MENUITEM "背景色(&B)", IDM_TIPBKCOLOR END END END MYMENU2 MENU DISCARDABLE BEGIN POPUP "ダミーです" BEGIN POPUP "ファイル(&F)" BEGIN MENUITEM "新規作成(&N)...\tCtrl+N", IDM_NEW MENUITEM "開く(&O)...\tCtrl+O", IDM_OPEN MENUITEM SEPARATOR MENUITEM "上書き保存(&S)\tCtrl+S", IDM_SAVE MENUITEM "名前を付けて保存(&A)...", IDM_SAVEAS MENUITEM SEPARATOR MENUITEM "アプリケーションの終了(&X)", IDM_END END POPUP "編集" BEGIN MENUITEM "元に戻す(&U)\tCtrl+Z", IDM_UNDO MENUITEM "切り取り(&T)\tCtrl+X", IDM_CUT MENUITEM "コピー(&C)\tCtrl+C", IDM_COPY MENUITEM "貼り付け(&]P)\tCtrl+V", IDM_PASTE MENUITEM "削除(&D)\tCtrl+D", IDM_DELETE MENUITEM SEPARATOR MENUITEM "すべて選択(&L)\tCtrl+A", IDM_ALL END POPUP "挿入(&I)" BEGIN MENUITEM "基本項目(&B)\tShift+Ctrl+B", IDM_BASICINPUT MENUITEM SEPARATOR POPUP "タグの挿入" BEGIN MENUITEM "<P>", IDM_P MENUITEM "<BR>", IDM_BR MENUITEM "<H*></H*>...", IDM_H MENUITEM "<IMG>...", IDM_IMAGE MENUITEM "<A HREF></A>...", IDM_A MENUITEM "<TABLE></TABLE>...", IDM_TABLE MENUITEM "<FORM></FORM>...", IDM_FORM MENUITEM "<INPUT>...", IDM_INPUT END POPUP "JavaScriptの挿入" BEGIN MENUITEM "<SCRIPT>", IDM_SCRIPT END POPUP "GIF画像" BEGIN MENUITEM "What's New", IDM_WHAT MENUITEM "Mail", IDM_MAILTO MENUITEM "Home", IDM_HOME MENUITEM "Index", IDM_INDEX MENUITEM "Back", IDM_BACK MENUITEM "Contents", IDM_CONTENTS END MENUITEM SEPARATOR POPUP "ダイレクト・アニメーション" BEGIN MENUITEM "テキスト", IDM_DIRECTANI_TEXT END END POPUP "ブラウザ(&B)" BEGIN MENUITEM "ブラウザの起動(&B)\tF12", IDM_BROWSER END POPUP "オプション(&O)" BEGIN POPUP "ツールチップ(&T)" BEGIN MENUITEM "文字色(&L)", IDM_TIPTXTCOLOR MENUITEM "背景色(&B)", IDM_TIPBKCOLOR END END END END
DllMain関数に変更はありません。//hedll03.cpp #include <windows.h> #include "hedll.h" #include "resource.h" int WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved) { return TRUE; }
本体の方のプログラムを次に示します。
dll側のリソースのIDM_DIRECTANI_TEXTの値をこのファイルで defineしてもよいですが、ここではresource.hに定義を追加しました。 VC++の人は、「ID」ボタンを押して、シンボルブラウザを出して「新規(N)」で 定義します。// htmledit.h #define IDM_FILE 41001 #define IDM_EDIT 41002 #define IDM_INSERT 41003 #define IDM_BRVIEW 41004 #define IDM_OPTION 41005 typedef struct _tagHData { char szTagNo[4]; char szContents[256]; } MYHTAG, *LPMYHTAG; typedef struct _tagImgData { char szFileName[MAX_PATH]; char szPath[MAX_PATH]; BOOL bPath; } MYIMGTAG, *LPMYIMGTAG; typedef struct _tagTableData { char szRow[8]; char szColumn[8]; char szTitle[64]; char szTitleAlign[16]; char szBorder[8]; BOOL bTitle; BOOL bBorder; } MYTABLETAG, *LPMYTABLETAG; typedef struct _tagFormData { char szMethod[8]; char szAction[64]; char szName[16]; char szID[16]; BOOL bMethod; BOOL bAction; BOOL bName; BOOL bID; } MYFORMTAG, *LPMYFORMTAG; typedef struct _tagInputData { char szType[16]; char szValue[64]; char szName[16]; char szID[16]; char szOnClick[64]; char szOnBlur[64]; char szOnChange[64]; char szOnFocus[64]; char szOnSubmit[64]; BOOL bValue; BOOL bName; BOOL bID; BOOL bClick; BOOL bBlur; BOOL bChange; BOOL bFocus; BOOL bSubmit; } MYINPUTTAG, *LPMYINPUTTAG; typedef struct _tagInitialData { int x; //ウィンドウx座標 int y; //y座標 int wx; //ウィンドウ幅 int wy; //ウィンドウ高さ COLORREF crTipText; COLORREF crTipBackground; } MYINITIALDATA, *LPMYINITIALDATA; typedef struct _tagDirectAniText { char szText[256]; char szObjectName[32]; char szObjectBorderStyle[16]; char szObjectBorderColor[16]; char szBackColor[16]; BOOL bBorder; int nObjectBorderWidth; int nObjectWidth; int nObjectHeight; int nX; int nY; int nRotate; char szLineColor[16]; char szFillColor[16]; int nLineStyle; int nLineWidth; char szFontName[64]; int nFontWidth; int nFontWeight; BOOL bItalic; BOOL bUnderLine; BOOL bStrikeOut; } MYDIRECTTEXT, *LPMYDIRECTTEXT;
_tagDirectAniText構造体の定義が増えました。
ダイレクト・アニメーションの挿入のいろいろな項目を記入する ダイアログが増えました。//htmledit15.rcの一部 ///////////////////////////////////////////////////////////////////////////// // // Dialog // MYBASICINPUT DIALOG DISCARDABLE 0, 0, 187, 121 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "基本項目入力" FONT 9, "MS Pゴシック" BEGIN EDITTEXT IDC_EDIT1,39,7,141,14,ES_AUTOHSCROLL EDITTEXT IDC_EDIT2,39,27,141,14,ES_AUTOHSCROLL EDITTEXT IDC_EDIT3,39,47,141,14,ES_AUTOHSCROLL DEFPUSHBUTTON "OK",IDOK,39,100,50,14 PUSHBUTTON "キャンセル",IDCANCEL,96,100,50,14 LTEXT "タイトル",IDC_STATIC,7,7,23,8 LTEXT "作者",IDC_STATIC,7,30,15,8 LTEXT "E-Mail",IDC_STATIC,7,47,20,8 CONTROL "色",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,35,76,23,10 CONTROL "壁紙",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,67,76,32, 10 GROUPBOX "背景",IDC_STATIC,26,67,133,26 CONTROL "指定しない",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,108, 76,46,10 END MYHTAG DIALOG DISCARDABLE 0, 0, 187, 93 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "見出しタグの挿入" FONT 9, "MS Pゴシック" BEGIN COMBOBOX IDC_COMBO1,51,7,18,68,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP EDITTEXT IDC_EDIT1,51,27,129,32,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN DEFPUSHBUTTON "OK",IDOK,40,72,50,14 PUSHBUTTON "キャンセル",IDCANCEL,95,72,50,14 LTEXT "大きさ",IDC_STATIC,7,7,32,11 LTEXT "コンテンツ",IDC_STATIC,7,27,39,10 END MYIMGTAG DIALOG DISCARDABLE 0, 0, 187, 91 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "イメージの挿入" FONT 9, "MS Pゴシック" BEGIN DEFPUSHBUTTON "OK",IDOK,43,70,41,14 PUSHBUTTON "キャンセル",IDCANCEL,101,70,41,14 CONTROL "パス付き",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,42,15 EDITTEXT IDC_EDIT1,50,7,107,16,ES_AUTOHSCROLL LTEXT "ファイル名",IDC_STATIC,7,33,38,11 EDITTEXT IDC_EDIT2,50,29,107,16,ES_AUTOHSCROLL PUSHBUTTON "参照",IDC_BUTTON1,160,31,20,15 CONTROL "画像を確認する",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,52,61,15 END MYTABLETAG DIALOG DISCARDABLE 0, 0, 95, 133 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "テーブルの挿入" FONT 9, "MS Pゴシック" BEGIN DEFPUSHBUTTON "OK",IDOK,7,112,33,14 PUSHBUTTON "キャンセル",IDCANCEL,46,112,33,14 LTEXT "行",IDC_STATIC,7,7,11,10 COMBOBOX IDC_COMBO1,29,7,23,58,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP LTEXT "列",IDC_STATIC,7,27,11,10 COMBOBOX IDC_COMBO2,29,25,23,55,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP CONTROL "BORDER",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,49,41,12 EDITTEXT IDC_EDIT1,51,48,34,14,ES_AUTOHSCROLL CONTROL "CAPTION",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,67,44,12 COMBOBOX IDC_COMBO3,51,67,34,45,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP EDITTEXT IDC_EDIT2,17,89,71,14,ES_AUTOHSCROLL END MYFORMTAG DIALOG DISCARDABLE 0, 0, 187, 103 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "フォームの挿入" FONT 9, "MS Pゴシック" BEGIN DEFPUSHBUTTON "OK",IDOK,38,82,50,14 PUSHBUTTON "キャンセル",IDCANCEL,97,82,50,14 CONTROL "METHOD",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,47,12 COMBOBOX IDC_COMBO1,65,7,52,41,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP CONTROL "ACTION",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,25,43,12 EDITTEXT IDC_EDIT1,65,25,114,12,ES_AUTOHSCROLL CONTROL "NAME",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, 7,43,34,12 EDITTEXT IDC_EDIT2,65,43,114,12,ES_AUTOHSCROLL CONTROL "ID",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, 61,32,12 EDITTEXT IDC_EDIT3,65,61,114,12,ES_AUTOHSCROLL END MYINPUTTAG DIALOG DISCARDABLE 0, 0, 135, 203 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "INPUTの挿入" FONT 9, "MS Pゴシック" BEGIN DEFPUSHBUTTON "OK",IDOK,17,182,50,14 PUSHBUTTON "キャンセル",IDCANCEL,71,182,50,14 LTEXT "TYPE",IDC_STATIC,7,7,24,9 COMBOBOX IDC_COMBO1,49,7,45,92,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP CONTROL "NAME",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, 7,48,35,14 CONTROL "ID",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, 67,25,14 CONTROL "onClick",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,86,35,14 EDITTEXT IDC_EDIT4,49,87,75,13,ES_AUTOHSCROLL EDITTEXT IDC_EDIT2,49,49,75,13,ES_AUTOHSCROLL EDITTEXT IDC_EDIT3,49,67,75,13,ES_AUTOHSCROLL EDITTEXT IDC_EDIT1,49,29,75,13,ES_AUTOHSCROLL CONTROL "VALUE",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, 7,29,37,14 CONTROL "onBlur",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,105,36,14 EDITTEXT IDC_EDIT5,49,105,75,13,ES_AUTOHSCROLL CONTROL "onChange",IDC_CHECK6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,124,40,14 EDITTEXT IDC_EDIT6,49,125,75,13,ES_AUTOHSCROLL CONTROL "onFocus",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,143,37,14 EDITTEXT IDC_EDIT7,49,143,75,13,ES_AUTOHSCROLL CONTROL "onSubmit",IDC_CHECK8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,162,40,14 EDITTEXT IDC_EDIT8,49,163,75,13,ES_AUTOHSCROLL END MYDIRECTTEXT DIALOG DISCARDABLE 0, 0, 179, 341 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "ダイレクト・アニメーション[テキスト回転]" FONT 9, "MS Pゴシック" BEGIN DEFPUSHBUTTON "OK",IDOK,7,320,50,14 PUSHBUTTON "キャンセル",IDCANCEL,122,320,50,14 LTEXT "テキスト",IDC_STATIC,7,7,29,11 EDITTEXT IDC_TEXT,36,7,131,15,ES_AUTOHSCROLL LTEXT "ラインカラー",IDC_STATIC,7,49,42,11 EDITTEXT IDC_LINECOLOR,57,46,57,14,ES_AUTOHSCROLL LTEXT "塗りつぶし色",IDC_STATIC,7,66,45,11 EDITTEXT IDC_LINEWIDTH,57,100,55,15,ES_AUTOHSCROLL LTEXT "ラインスタイル",IDC_STATIC,7,83,46,14 LTEXT "ライン幅",IDC_STATIC,7,101,32,12 LTEXT "フォント名",IDC_STATIC,7,125,35,12 EDITTEXT IDC_FONTNAME,57,119,82,15,ES_AUTOHSCROLL LTEXT "フォント高さ",IDC_STATIC,7,145,35,12 EDITTEXT IDC_FONTHEIGHT,57,141,31,15,ES_AUTOHSCROLL LTEXT "太さ",IDC_STATIC,98,141,23,13 EDITTEXT IDC_FONTWEIGHT,124,139,43,15,ES_AUTOHSCROLL CONTROL "イタリック",IDC_ITALIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,161,47,14 CONTROL "アンダーライン",IDC_UNDERLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,64,160,59,15 CONTROL "取消線",IDC_STRIKEOUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,129,160,33,15 LTEXT "位置(",IDC_STATIC,24,29,19,11 EDITTEXT IDC_X,47,27,23,15,ES_AUTOHSCROLL LTEXT ",",IDC_STATIC,73,27,8,12 EDITTEXT IDC_Y,83,27,23,15,ES_AUTOHSCROLL LTEXT ")",IDC_STATIC,108,27,8,11 LTEXT "回転",IDC_STATIC,117,27,17,11 EDITTEXT IDC_ROTATE,137,26,28,15,ES_AUTOHSCROLL EDITTEXT IDC_FILLCOLOR,57,62,57,14,ES_AUTOHSCROLL COMBOBOX IDC_LINESTYLE,57,81,54,54,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "参照",IDC_LINECOLORBTN,120,44,26,16 PUSHBUTTON "参照",IDC_FILLCOLORBTN,120,60,26,16 PUSHBUTTON "参照",IDC_FONTBTN,146,119,26,16 LTEXT "オブジェクト名",IDC_STATIC,15,192,48,11 EDITTEXT IDC_OBJECTNAME,65,190,68,15,ES_AUTOHSCROLL LTEXT "幅",IDC_STATIC,15,211,11,8 EDITTEXT IDC_OBJECTWIDTH,29,207,40,14,ES_AUTOHSCROLL LTEXT "高さ",IDC_STATIC,74,212,20,8 EDITTEXT IDC_OBJECTHEIGHT,95,209,40,14,ES_AUTOHSCROLL LTEXT "境界スタイル",IDC_STATIC,18,247,44,11 COMBOBOX IDC_BORDERSTYLE,62,243,44,62,CBS_DROPDOWN | CBS_SORT | WS_DISABLED | WS_VSCROLL | WS_TABSTOP LTEXT "境界色",IDC_STATIC,17,264,29,11 EDITTEXT IDC_BORDERCOLOR,62,261,57,14,ES_AUTOHSCROLL | WS_DISABLED PUSHBUTTON "参照",IDC_BORDERCOLORBTN,125,261,26,14,WS_DISABLED LTEXT "境界幅",IDC_STATIC,17,279,35,12 EDITTEXT IDC_BORDERWIDTH,62,279,29,13,ES_AUTOHSCROLL | WS_DISABLED GROUPBOX "オブジェクト",IDC_STATIC,7,181,155,135 LTEXT "背景色",IDC_STATIC,17,297,26,10 EDITTEXT IDC_BACKCOLOR,62,297,57,14,ES_AUTOHSCROLL | WS_DISABLED PUSHBUTTON "参照",IDC_BACKCOLORBTN,125,297,26,14,WS_DISABLED CONTROL "境界を付ける",IDC_ISBORDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,227,54,14 END ///////////////////////////////////////////////////////////////////////////// // // Icon // // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. MYICON ICON DISCARDABLE "htmledit.ico" ///////////////////////////////////////////////////////////////////////////// // // Toolbar // IDR_TOOLBAR3X TOOLBAR DISCARDABLE 16, 15 BEGIN BUTTON ID_BUTTON40035 BUTTON ID_BUTTON40036 BUTTON ID_BUTTON40037 END IDR_TOOLBAR3 TOOLBAR DISCARDABLE 16, 15 BEGIN BUTTON ID_BUTTON40041 BUTTON ID_BUTTON40042 BUTTON ID_BUTTON40043 END ///////////////////////////////////////////////////////////////////////////// // // Bitmap // IDR_TOOLBAR3X BITMAP DISCARDABLE "toolbar3x.bmp" IDR_TOOLBAR3 BITMAP DISCARDABLE "toolbar3.bmp" ///////////////////////////////////////////////////////////////////////////// // // Accelerator // MYACCEL ACCELERATORS DISCARDABLE BEGIN "A", IDM_ALL, VIRTKEY, CONTROL, NOINVERT "B", IDM_BASICINPUT, VIRTKEY, SHIFT, CONTROL, NOINVERT "D", IDM_DELETE, VIRTKEY, CONTROL, NOINVERT "N", IDM_NEW, VIRTKEY, CONTROL, NOINVERT "O", IDM_OPEN, VIRTKEY, CONTROL, NOINVERT "S", IDM_SAVE, VIRTKEY, CONTROL, NOINVERT "V", IDM_PASTE, VIRTKEY, CONTROL, NOINVERT VK_F12, IDM_BROWSER, VIRTKEY, NOINVERT END ///////////////////////////////////////////////////////////////////////////// // // String Table // STRINGTABLE DISCARDABLE BEGIN IDS_FILE "ファイル(&F)" IDS_EDIT "編集(&E)" IDS_INSERT "挿入(&I)" IDS_BROWSER "ブラウザ(&B)" IDS_OPTION "オプション(&O)" END
MyDirectAniText, MyDirectColor, MyGetColor, MyDirectFont関数のプロトタイプ宣言が増えました。// htmedit15.cpp #ifndef STRICT #define STRICT #endif #define ID_EDIT 100 #define ID_EDIT2 101 #define ID_TOOL1 102 #define ID_TOOL2 103 #define ID_TOOL3 104 #define ID_REBAR 105 #define ID_STATIC 106 #define ID_STATUS 107 #define ID_TOOLMENU 108 #define ID_TIP1 111 #define ID_TIP2 112 #define ID_TIP3 113 #define MY_BUF_SIZE 1024 * 64 - 1 #define MY_MSG WM_USER #include <windows.h> #include <windowsx.h> #include "resource.h" #include "htmledit.h" #include <commctrl.h> #include "hedll.h" LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK MyBasicInputProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK MyHProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK MyImgProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK MyAProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK MyTableProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK MyFormProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK MyInputProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK NewEditProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK KbdHook(int, WPARAM, LPARAM lParam); LRESULT CALLBACK MyDirectTextProc(HWND, UINT, WPARAM, LPARAM); ATOM InitApp(HINSTANCE); BOOL InitInstance(HINSTANCE, int); BOOL MySetHTML(HWND, HWND); int MyBasicInput(HWND); BOOL MySaveAs(HWND); BOOL MySave(HWND); BOOL MyInsertTag(HWND, HWND, char *); BOOL MyInsertH(HWND, HWND); BOOL MyInsertIMG(HWND, HWND); BOOL MyGetFileTitle(HWND, HWND, BOOL); BOOL MyGetBodyColor(HWND); BOOL MyGetWallPaper(HWND); BOOL MyInsertA(HWND, HWND); BOOL MyGetHREFFile(HWND, HWND, BOOL); BOOL MyInsertTable(HWND, HWND); BOOL MyInsertForm(HWND, HWND); BOOL MyInsertInput(HWND, HWND); BOOL MyInsertScript(HWND, HWND); HWND MakeMyToolbar(HWND, int, TBBUTTON *, int); HWND MakeMyToolbar2(HWND, int, TBBUTTON *, int, int, int); HWND MakeMyToolbarMenu(HWND); BOOL MyOpen(HWND, HWND); BOOL CheckMyMenu(HMENU, HWND, HWND); BOOL CanPaste(HWND); BOOL MySetStatusText(HWND, int, char *); HWND MakeMyToolTip(HWND, HWND, int, int, TBBUTTON *, char [][256]); void SetTipColor(HWND, HWND *, COLORREF *, int); void SetTipBkColor(HWND, HWND *, COLORREF *, int); BOOL GetInitialSetting(LPMYINITIALDATA); BOOL SetInitialSetting(LPMYINITIALDATA); BOOL ShowMyPopMenu(HWND, HWND, char *, int, HWND, HWND); BOOL MyCreateFileFromResource(HWND, HWND, char *, char *, char *); BOOL MyDirectAniText(HWND, HWND); BOOL MyDirectColor(HWND, HWND); COLORREF MyGetColor(HWND); BOOL MyDirectFont(HWND, HWND, HWND, HWND, HWND, HWND, HWND, HWND, LPMYDIRECTTEXT); char szClassName[] = "htmedit15"; //ウィンドウクラス char szExeName[] = "hedll03.dll"; //dllの名前 char *lpszWinTitleOrg = "猫でもわかるHTMLエディタ[%s]"; char *lpszHead = "<HTML>\r\n<HEAD>\r\n" "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=x-sjis\">\r\n<TITLE>"; char szTitle[64] = "タイトル"; char *lpszBody1 = "</TITLE>\r\n</HEAD>\r\n<BODY"; char szBody2[256]; char *lpszBody3 =">\r\n"; char *lpszAddress = "<ADDRESS>"; char *lpszMailto = "<A HREF=\"mailto:"; char szEMail[256] = "webmaster@kumei.ne.jp"; char *lpszMailEnd = "\">"; char szAuthor[64] = "Yasutaka Kumei"; char *lpszCloseA = "</A>"; char *lpszEnd = "</ADDRESS>\r\n</BODY>\r\n</HTML>"; char szFileName[MAX_PATH]; char szFileTitle[64]; WNDPROC OrgEditProc; HIMAGELIST hImage; HWND hParent; HHOOK hHook; HWND hMytoolMenu; HWND hTool2_g, hEdit_g; HINSTANCE hDllInst; //dllのインスタンス TBBUTTON tbButton1[] = { {STD_FILENEW, IDM_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0}, {STD_FILEOPEN, IDM_OPEN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0}, {STD_FILESAVE, IDM_SAVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0}, }; TBBUTTON tbButton2[] = { {STD_COPY, IDM_COPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0}, {STD_CUT, IDM_CUT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0}, {STD_PASTE, IDM_PASTE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0}, {STD_DELETE, IDM_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0}, {STD_UNDO, IDM_UNDO, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0}, }; TBBUTTON tbButton3[] = { {0, IDM_BASICINPUT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0}, {1, IDM_SCRIPT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0}, {2, IDM_TAG, TBSTATE_ENABLED, TBSTYLE_DROPDOWN, 0, 0, 0}, }; TBBUTTON tbButtonMenu[] = { {I_IMAGENONE, IDM_FILE, TBSTATE_ENABLED, TBSTYLE_BUTTON | BTNS_AUTOSIZE, 0, 0, 0}, {I_IMAGENONE, IDM_EDIT, TBSTATE_ENABLED, TBSTYLE_BUTTON | BTNS_AUTOSIZE, 0, 0, 0}, {I_IMAGENONE, IDM_INSERT, TBSTATE_ENABLED, TBSTYLE_BUTTON | BTNS_AUTOSIZE, 0, 0, 0}, {I_IMAGENONE, IDM_BRVIEW, TBSTATE_ENABLED, TBSTYLE_BUTTON | BTNS_AUTOSIZE, 0, 0, 0}, {I_IMAGENONE, IDM_OPTION, TBSTATE_ENABLED, TBSTYLE_BUTTON | BTNS_AUTOSIZE, 0, 0, 0} }; char szTipText1[][256] = { "新規にHTMLファイルを作成します", "HTMLファイルを開きます", "上書き保存をします\nすでに名前を付けて保存してある必要があります" }; char szTipText2[][256] = { "選択された文字列をコピーします", "選択された文字列を切り取って\nクリップボードに格納します", "クリップボードから貼り付けます", "選択された文字列を削除します\n削除してしまってもUNDOで取り消すこともできます", "元に戻します" }; char szTipText3[][256] = { "HTMLの基本的枠組みを作ります", "スクリプトを挿入します", "タグを挿入します" };
WinMain, InitApp, InitInstanceの各関数に変更はありません。
メニューの「挿入」「ダイレクト・アニメーション」「テキスト」に対応する 部分が増えました。//ウィンドウプロシージャ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { ...省略 switch (msg) { ...省略 case WM_COMMAND: ...省略 case IDM_DIRECTANI_TEXT: MyDirectAniText(hEdit, hEdit_hide); break; } ...省略
あとの部分に特に変更はありません。今回追加になった関数を次に示します。
この関数が呼ばれたら、まず"MYDIRECTTEXT"ダイアログボックスを出します。 この時mydirectのアドレスを渡します。これは、このダイアログボックスのプロシージャで WM_INITDIALOGメッセージのLPARAMとして渡されます。BOOL MyDirectAniText(HWND hEdit, HWND hEdit_hide) { HINSTANCE hInst; MYDIRECTTEXT mydirect; char szBuf[64]; hInst = (HINSTANCE)GetWindowLong(hEdit, GWL_HINSTANCE); if (DialogBoxParam(hInst, "MYDIRECTTEXT", hEdit, (DLGPROC)MyDirectTextProc, (LPARAM)&mydirect) != IDOK) return FALSE; MyInsertTag(hEdit, hEdit_hide, "<OBJECT CLASSID=\"clsid:369303c2-d7ac-11d0-89d5-00a0c90833e6\"\r\n"); MyInsertTag(hEdit, hEdit_hide, " ID=\""); MyInsertTag(hEdit, hEdit_hide, mydirect.szObjectName); MyInsertTag(hEdit, hEdit_hide, "\" STYLE=\"width:"); _itoa(mydirect.nObjectWidth, szBuf, 10); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ";height:"); _itoa(mydirect.nObjectHeight, szBuf, 10); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ";"); if (mydirect.bBorder) { MyInsertTag(hEdit, hEdit_hide, "border:"); _itoa(mydirect.nObjectBorderWidth, szBuf, 10); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, " "); MyInsertTag(hEdit, hEdit_hide, mydirect.szObjectBorderStyle); MyInsertTag(hEdit, hEdit_hide, " rgb("); MyInsertTag(hEdit, hEdit_hide, mydirect.szObjectBorderColor); MyInsertTag(hEdit, hEdit_hide, "); background:rgb("); MyInsertTag(hEdit, hEdit_hide, mydirect.szBackColor); MyInsertTag(hEdit, hEdit_hide, ");"); } MyInsertTag(hEdit, hEdit_hide, "\">\r\n"); MyInsertTag(hEdit, hEdit_hide, "<PARAM NAME=\"Line0001\" VALUE=\"SetLineColor("); MyInsertTag(hEdit, hEdit_hide, mydirect.szLineColor); MyInsertTag(hEdit, hEdit_hide, ")\">\r\n"); MyInsertTag(hEdit, hEdit_hide, "<PARAM NAME=\"Line0002\" VALUE=\"SetFillColor("); MyInsertTag(hEdit, hEdit_hide, mydirect.szFillColor); MyInsertTag(hEdit, hEdit_hide, ")\">\r\n"); MyInsertTag(hEdit, hEdit_hide, "<PARAM NAME=\"Line0003\" VALUE=\"SetLineStyle("); _itoa(mydirect.nLineStyle, szBuf, 10); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ", "); _itoa(mydirect.nLineWidth, szBuf, 10); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ")\">\r\n"); MyInsertTag(hEdit, hEdit_hide, "<PARAM NAME=\"Line0004\" VALUE=\"SetFont('"); MyInsertTag(hEdit, hEdit_hide, mydirect.szFontName); MyInsertTag(hEdit, hEdit_hide, "', "); _itoa(mydirect.nFontWidth, szBuf, 10); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ", "); _itoa(mydirect.nFontWeight, szBuf, 10); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ", "); if (mydirect.bItalic) strcpy(szBuf, "-1"); else strcpy(szBuf, "0"); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ", "); if (mydirect.bUnderLine) strcpy(szBuf, "-1"); else strcpy(szBuf, "0"); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ", "); if (mydirect.bStrikeOut) strcpy(szBuf, "-1"); else strcpy(szBuf, "0"); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ")\">\r\n"); MyInsertTag(hEdit, hEdit_hide, "<PARAM NAME=\"Line0005\" VALUE=\"Text('"); MyInsertTag(hEdit, hEdit_hide, mydirect.szText); MyInsertTag(hEdit, hEdit_hide, "', "); _itoa(mydirect.nX, szBuf, 10); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ", "); _itoa(mydirect.nY, szBuf, 10); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ", "); _itoa(mydirect.nRotate, szBuf, 10); MyInsertTag(hEdit, hEdit_hide, szBuf); MyInsertTag(hEdit, hEdit_hide, ")\">\r\n</OBJECT>"); return TRUE; }
DialogBoxParam関数の戻り値がIDOK以外の時はFALSEをreturnして、この関数を終了します。 IDOKの時はMyInsertTag関数で必要なタグを挿入していきます。
今回新たに作ったダイアログのプロシージャです。LRESULT CALLBACK MyDirectTextProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp) { static LPMYDIRECTTEXT lpmytxt; static HWND hText, hX, hY, hRotate, hLineColor, hFillColor, hLineStyle, hLineWidth, hFontName, hFontHeight, hFontWeight, hItalic, hUnderLine, hStrikeOut, hLineColorBtn, hFillColorBtn, hFontBtn, hObjectName, hObjectWidth, hObjectHeight, hBorderWidth, hBorderColor, hBorderStyle, hBorderColorBtn, hBackColor, hBackColorBtn, hIsBorder; char szBuf[256]; switch (msg) { case WM_INITDIALOG: lpmytxt = (LPMYDIRECTTEXT)lp; hText = GetDlgItem(hDlg, IDC_TEXT); hX = GetDlgItem(hDlg, IDC_X); hY = GetDlgItem(hDlg, IDC_Y); hRotate = GetDlgItem(hDlg, IDC_ROTATE); hLineColor = GetDlgItem(hDlg, IDC_LINECOLOR); hLineStyle = GetDlgItem(hDlg, IDC_LINESTYLE); hLineWidth = GetDlgItem(hDlg, IDC_LINEWIDTH); hFillColor = GetDlgItem(hDlg, IDC_FILLCOLOR); hFontName = GetDlgItem(hDlg, IDC_FONTNAME); hFontHeight = GetDlgItem(hDlg, IDC_FONTHEIGHT); hFontWeight = GetDlgItem(hDlg, IDC_FONTWEIGHT); hItalic = GetDlgItem(hDlg, IDC_ITALIC); hUnderLine = GetDlgItem(hDlg, IDC_UNDERLINE); hStrikeOut = GetDlgItem(hDlg, IDC_STRIKEOUT); hLineColorBtn = GetDlgItem(hDlg, IDC_LINECOLORBTN); hFillColorBtn = GetDlgItem(hDlg, IDC_FILLCOLORBTN); hFontBtn = GetDlgItem(hDlg, IDC_FONTBTN); hObjectName = GetDlgItem(hDlg, IDC_OBJECTNAME); hObjectWidth = GetDlgItem(hDlg, IDC_OBJECTWIDTH); hObjectHeight = GetDlgItem(hDlg, IDC_OBJECTHEIGHT); ComboBox_InsertString(hLineStyle, 0, "破線"); ComboBox_InsertString(hLineStyle, 0, "実線"); ComboBox_InsertString(hLineStyle, 0, "なし"); hBorderColor = GetDlgItem(hDlg, IDC_BORDERCOLOR); hBorderStyle = GetDlgItem(hDlg, IDC_BORDERSTYLE); hBorderColorBtn = GetDlgItem(hDlg, IDC_BORDERCOLORBTN); hBorderWidth = GetDlgItem(hDlg, IDC_BORDERWIDTH); ComboBox_InsertString(hBorderStyle, 0, "none"); ComboBox_InsertString(hBorderStyle, 0, "double"); ComboBox_InsertString(hBorderStyle, 0, "dotted"); ComboBox_InsertString(hBorderStyle, 0, "dashed"); ComboBox_InsertString(hBorderStyle, 0, "solid"); hBackColor = GetDlgItem(hDlg, IDC_BACKCOLOR); hBackColorBtn = GetDlgItem(hDlg, IDC_BACKCOLORBTN); hIsBorder = GetDlgItem(hDlg, IDC_ISBORDER); return true; case WM_COMMAND: switch (LOWORD(wp)) { case IDOK: Edit_GetText(hText, lpmytxt->szText, 256); Edit_GetText(hObjectName, lpmytxt->szObjectName, 32); Edit_GetText(hObjectWidth, szBuf, 256); lpmytxt->nObjectWidth = atoi(szBuf); Edit_GetText(hObjectHeight, szBuf, 256); lpmytxt->nObjectHeight = atoi(szBuf); Edit_GetText(hX, szBuf, 256); lpmytxt->nX = atoi(szBuf); Edit_GetText(hY, szBuf, 256); lpmytxt->nY = atoi(szBuf); Edit_GetText(hRotate, szBuf, 256); lpmytxt->nRotate = atoi(szBuf); Edit_GetText(hLineColor, lpmytxt->szLineColor, 16); Edit_GetText(hFillColor, lpmytxt->szFillColor, 16); ComboBox_GetText(hLineStyle, szBuf, 256); if (strcmp(szBuf, "なし") == 0) lpmytxt->nLineStyle = 0; if (strcmp(szBuf, "実線") == 0) lpmytxt->nLineStyle = 1; if (strcmp(szBuf, "破線") == 0) lpmytxt->nLineStyle = 2; Edit_GetText(hLineWidth, szBuf, 256); lpmytxt->nLineWidth = atoi(szBuf); Edit_GetText(hFontName, lpmytxt->szFontName, 64); Edit_GetText(hFontHeight, szBuf, 256); lpmytxt->nFontWidth = atoi(szBuf); Edit_GetText(hFontWeight, szBuf, 256); lpmytxt->nFontWeight = atoi(szBuf); if (Button_GetCheck(hItalic) == BST_CHECKED) lpmytxt->bItalic = TRUE; else lpmytxt->bItalic = FALSE; if (Button_GetCheck(hUnderLine) == BST_CHECKED) lpmytxt->bUnderLine = TRUE; else lpmytxt->bUnderLine = FALSE; if (Button_GetCheck(hStrikeOut) == BST_CHECKED) lpmytxt->bStrikeOut = TRUE; else lpmytxt->bStrikeOut = FALSE; ComboBox_GetText(hBorderStyle, lpmytxt->szObjectBorderStyle, 16); ComboBox_GetText(hBorderWidth, szBuf, 64); lpmytxt->nObjectBorderWidth = atoi(szBuf); ComboBox_GetText(hBorderColor, lpmytxt->szObjectBorderColor, 16); Edit_GetText(hBackColor, lpmytxt->szBackColor, 16); if (Button_GetCheck(hIsBorder) == BST_CHECKED) lpmytxt->bBorder = TRUE; else lpmytxt->bBorder =FALSE; EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; case IDC_LINECOLORBTN: MyDirectColor(hDlg, hLineColor); break; case IDC_FILLCOLORBTN: MyDirectColor(hDlg, hFillColor); break; case IDC_FONTBTN: MyDirectFont(hDlg, hFontName, hFontHeight, hFontWeight, hItalic, hUnderLine, hStrikeOut, hFillColor, lpmytxt); break; case IDC_BORDERCOLORBTN: MyDirectColor(hDlg, hBorderColor); break; case IDC_BACKCOLORBTN: MyDirectColor(hDlg, hBackColor); break; case IDC_ISBORDER: if (Button_GetCheck(hIsBorder) == BST_CHECKED) { EnableWindow(hBorderStyle, TRUE); EnableWindow(hBorderColor, TRUE); EnableWindow(hBorderWidth, TRUE); EnableWindow(hBackColor, TRUE); EnableWindow(hBorderColorBtn, TRUE); EnableWindow(hBackColorBtn, TRUE); } else { EnableWindow(hBorderStyle, FALSE); EnableWindow(hBorderColor, FALSE); EnableWindow(hBorderWidth, FALSE); EnableWindow(hBackColor, FALSE); EnableWindow(hBorderColorBtn, FALSE); EnableWindow(hBackColorBtn, FALSE); } break; } return FALSE; } return FALSE; }
WM_INITDIALOGメッセージが来たら、LPARAMの値をlpmytxtにコピーしておきます。 また、ダイアログボックスのエディットコントロールなどのウィンドウハンドルを取得しておきます。
OKボタンが押されたら、ダイアログに記入されているいろいろな項目をlpmytxtに書き込みます。
IDC_LINECOLORBTN, IDC_FILLCOLORBTN, IDC_BORDERCOLORBTN, IDC_BACKCOLORBTN が来たらMyDirectColor関数を呼びます。
IDC_FONTBTNが来たらMyDirectFont関数を呼びます。
IDC_ISBORDERが来たら、チェックボックスのチェックの有無によりエディットコントロールなどを 有効にしたり無効にしたりします。
この関数が呼ばれたら、まずMyGetColor関数を呼びます。 そうすると色選択ダイアログで選択されたRGB値が戻ってきます。 これをGetR(G,B)Valueマクロで、各コンポーネントの値を取得します。 これを"r,g,b"の形の文字列にしてダイアログボックスのエディットコントロールに 書き込みます。BOOL MyDirectColor(HWND hDlg, HWND hColor) { char szR[8], szG[8], szB[8]; COLORREF crLine; char szBuf[128]; crLine = MyGetColor(hDlg); wsprintf(szR, "%d", GetRValue(crLine)); wsprintf(szG, "%d", GetGValue(crLine)); wsprintf(szB, "%d", GetBValue(crLine)); wsprintf(szBuf, "%s, %s, %s", szR, szG, szB); Edit_SetText(hColor, szBuf); return TRUE; }
色選択ダイアログを出して、選択した色値を返します。COLORREF MyGetColor(HWND hDlg) { CHOOSECOLOR cc; static COLORREF crResult = RGB(0, 0, 0); static DWORD dwCustColor[16]; memset(&cc, 0, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hDlg; cc.rgbResult = crResult; cc.Flags = CC_RGBINIT; cc.lpCustColors = dwCustColor; if (ChooseColor(&cc)) { crResult = cc.rgbResult; return cc.rgbResult; } return RGB(0, 0, 0); }
フォント選択ダイアログを出して、選択されたフォントのいろいろな値を 呼び出し側のダイアログボックスのエディットコントロールに書き込みます。BOOL MyDirectFont(HWND hDlg, HWND hFontName, HWND hFontHeight, HWND hFontWeight, HWND hItalic, HWND hUnderLine, HWND hStrikeOut, HWND hFillColor, LPMYDIRECTTEXT lpmytxt) { static LOGFONT lf; CHOOSEFONT cf; HINSTANCE hInst; static COLORREF crCol; char szBuf[64], szR[4], szG[4], szB[4]; hInst = (HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE); lf.lfCharSet = DEFAULT_CHARSET; memset(&cf, 0, sizeof(CHOOSEFONT)); cf.lStructSize = sizeof(CHOOSEFONT); cf.hwndOwner = hDlg; cf.lpLogFont = &lf; cf.hInstance = hInst; cf.lpTemplateName = "MYFONTDLG"; cf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_INITTOLOGFONTSTRUCT; cf.rgbColors = crCol; ChooseFont(&cf); crCol = cf.rgbColors; Edit_SetText(hFontName, lf.lfFaceName); if (lf.lfUnderline) Button_SetCheck(hUnderLine, BST_CHECKED); else Button_SetCheck(hUnderLine, BST_UNCHECKED); if (lf.lfItalic) Button_SetCheck(hItalic, BST_CHECKED); else Button_SetCheck(hItalic, BST_UNCHECKED); if (lf.lfStrikeOut) Button_SetCheck(hStrikeOut, BST_CHECKED); else Button_SetCheck(hStrikeOut, BST_UNCHECKED); wsprintf(szBuf, "%d", lf.lfWeight); Edit_SetText(hFontWeight, szBuf); if (lf.lfHeight < 0) wsprintf(szBuf, "%d", -1 * lf.lfHeight); else wsprintf(szBuf, "%d", lf.lfHeight); Edit_SetText(hFontHeight, szBuf); wsprintf(szR, "%d", GetRValue(cf.rgbColors)); wsprintf(szG, "%d", GetGValue(cf.rgbColors)); wsprintf(szB, "%d", GetBValue(cf.rgbColors)); wsprintf(szBuf, "%s, %s, %s", szR, szG, szB); Edit_SetText(hFillColor, szBuf); return TRUE; }
ダイアログボックスの項目が多いので、ちょっと面倒くさいところがありますが、 プログラム自体は特に難しくはないですね。
Update 22/Sep/2001 By Y.Kumei