ここをクリックするとパスコントロールのサンプルを見ることができます(IE4.0以降のみ)。
具体的なタグを次に示します。
<OBJECT ID="neko" CLASSID="CLSID:D7A7D7C3-D47F-11D0-89D3-00A0C90833E6"> <PARAM NAME="AutoStart" VALUE="-1"> <PARAM NAME="Repeat" VALUE="-1"> <PARAM NAME="Bounce" VALUE="0"> <PARAM NAME="Duration" VALUE="5"> <PARAM NAME="Shape" VALUE="PolyLine(4, 0, 0, 100, 0, 100, 120, 10, 0)"> <PARAM NAME="Target" VALUE="target"> <PARAM NAME="TimerInterval" VALUE="0.05"> </OBJECT> |
CLASSIDは固有の値なのでこのまま使います。
AutoStartが0の場合は自動的にスタートしません。0以外の時は自動スタートです。
Repeatは-1の時は永久に繰り返します。0は繰り返し無しです。その他の数値はその回数だけ 繰り返します。
Durationは1周するまでの時間(秒)を指定します。
Shapeは形を指定します。この形に沿ってオブジェクトが移動します。
Oval, Rect, Polylineから選択します。前2者は座標として2点を指定します。
Oval(0, 0, 200, 100)
なら、(0, 0, 200, 100)の矩形に収まる楕円を示します。
Polylineの場合は、最初に頂点の数、次にそれぞれの頂点の座標を指定します。
Targetには、移動するオブジェクトを指定します。注意点としては 移動されるオブジェクトのSTYLEにposition:absolute; が指定されていなくてはなりません。これを忘れると動きません。 オブジェクトは<DIV>,<TABLE>,<P>,<IMG>などIDの指定できるものであれば何でもかまいません。
TimeIntervalには、再描画の時間を指定します。
では、プログラムを見てみましょう。今回はdllに分離した部分をまた、元に戻してみました。 また、本体のhInstを必要とするところがいくつか有るので、これをグローバル変数にしました。
MYDIRECTANIPATH構造体の定義が増えました。// 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; typedef struct _tagDirectAniPath { char szObjectID[32]; BOOL bAutoStart; BOOL bRepeat; char szRepeatNo[8]; BOOL bBounce; char szDuration[16]; char szShape[16]; char szCoordinate[64]; char szTarget[32]; char szTimerInterval[16]; } MYDIRECTANIPATH, *LPMYDIRECTANIPATH;
メニューに「パスコントロール」が増えました。// htmledit17.rcの一部 ///////////////////////////////////////////////////////////////////////////// // // 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 ///////////////////////////////////////////////////////////////////////////// // // GIF // BACK GIF DISCARDABLE "back.gif" HOME GIF DISCARDABLE "home.gif" MAIL GIF DISCARDABLE "mail.gif" WHAT GIF DISCARDABLE "what.gif" INDEX GIF DISCARDABLE "index.gif" CONTENTS GIF DISCARDABLE "contents.gif" ///////////////////////////////////////////////////////////////////////////// // // 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 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 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 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 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 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 MYDIRECTPATH DIALOG DISCARDABLE 0, 0, 155, 271 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "ダイレクト・アニメーション[パス移動]" FONT 9, "MS Pゴシック" BEGIN CONTROL "オートスタート",IDC_AUTOSTART,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,58,14 CONTROL "バウンド",IDC_BOUNCE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,86,7,39,14 CONTROL "リピート",IDC_REPEAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,40,41,14 EDITTEXT IDC_REPEATEDIT,75,35,69,20,ES_AUTOHSCROLL LTEXT "このオブジェクトのID",IDC_STATIC,7,69,64,12 EDITTEXT IDC_OBJECTID,75,63,69,20,ES_AUTOHSCROLL LTEXT "終点までの時間",IDC_STATIC,7,98,54,14 EDITTEXT IDC_DURATION,75,92,69,20,ES_AUTOHSCROLL LTEXT "ターゲット",IDC_STATIC,7,127,36,14 EDITTEXT IDC_TARGET,75,120,69,20,ES_AUTOHSCROLL LTEXT "形状",IDC_STATIC,7,151,60,14 COMBOBOX IDC_SHAPE,76,147,68,59,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP LTEXT "座標 (多角形の場合は最初に頂点の数)",IDC_STATIC,7,179, 65,23 EDITTEXT IDC_COORDINATE,75,171,69,35,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN LTEXT "インターバル",IDC_STATIC,7,217,45,14 EDITTEXT IDC_INTERVAL,75,213,69,20,ES_AUTOHSCROLL DEFPUSHBUTTON "OK",IDOK,24,250,50,14 PUSHBUTTON "キャンセル",IDCANCEL,93,250,50,14 END ///////////////////////////////////////////////////////////////////////////// // // Icon // // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. MYICON ICON DISCARDABLE "htmledit.ico" ///////////////////////////////////////////////////////////////////////////// // // Menu // 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 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 MENUITEM "パスコントロール", IDM_DIRECTANI_PATH END 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 MENUITEM "パスコントロール", IDM_DIRECTANI_PATH 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_DIRECTANI_TEXT2 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 MENUITEM "パスコントロール", IDM_DIRECTANI_PATH 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 ///////////////////////////////////////////////////////////////////////////// // // Toolbar // IDR_TOOLBAR3 TOOLBAR DISCARDABLE 16, 15 BEGIN BUTTON ID_BUTTON40041 BUTTON ID_BUTTON40042 BUTTON ID_BUTTON40043 END IDR_TOOLBAR3X TOOLBAR DISCARDABLE 16, 15 BEGIN BUTTON ID_BUTTON40035 BUTTON ID_BUTTON40036 BUTTON ID_BUTTON40037 END ///////////////////////////////////////////////////////////////////////////// // // Bitmap // IDR_TOOLBAR3 BITMAP DISCARDABLE "toolbar3.bmp" IDR_TOOLBAR3X BITMAP DISCARDABLE "toolbar3x.bmp" ///////////////////////////////////////////////////////////////////////////// // // String Table // STRINGTABLE DISCARDABLE BEGIN IDS_FILE "ファイル(&F)" IDS_EDIT "編集(&E)" IDS_INSERT "挿入(&I)" IDS_BROWSER "ブラウザ(&B)" IDS_OPTION "オプション(&O)" END
また、これに関連したダイアログボックスが増えました。
hedll.hは不要となったのでincludeからはずしました。// htmedit17.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 "htmledit.h" #include "resource.h" #include <commctrl.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); LRESULT CALLBACK MyDirectPathProc(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); BOOL MyDirectAniPath(HWND, HWND); char szClassName[] = "htmedit17"; //ウィンドウクラス char szExeName[] = "htmledit17.exe"; //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 hInst; 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の基本的枠組みを作ります", "スクリプトを挿入します", "タグを挿入します" };
新たにMyDirectPathProcプロシージャの宣言が増えました。
MyDirectAniPath関数が増えました。
szExeNameをこのプログラムの名前にします。これを間違えるとGIF画像の 挿入などが出来なくなります。
hInstをグローバル変数にしました。
WinMain関数が始まったらすぐにインスタンスハンドルをグローバル変数にコピーしています。int WINAPI WinMain(HINSTANCE hCurInst, HINSTANCE hPrevInst, LPSTR lpsCmdLine, int nCmdShow) { MSG msg; HACCEL hAccel; hInst = hCurInst; if (!InitApp(hCurInst)) return FALSE; if (!InitInstance(hCurInst, nCmdShow)) return FALSE; hAccel = LoadAccelerators(hCurInst, "MYACCEL"); if (hParent == NULL) { MessageBox(NULL, "ハンドルなし", "", MB_OK); return 0; } while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(hParent, hAccel, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; }
LoadAccelerators関数の第1引数をhCurInstにしています。あるいは、hInstでも同じことです。
LoadIcon関数の第1引数をhInstに戻します。//ウィンドウ・クラスの登録 ATOM InitApp(HINSTANCE hInst) { WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; //プロシージャ名 wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInst;//インスタンス wc.hIcon = LoadIcon(hInst, "MYICON"); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // wc.lpszMenuName = "MYMENU"; //メニュー名 wc.lpszClassName = (LPCSTR)szClassName; wc.hIconSm = LoadIcon(hInst, "MYICON"); return (RegisterClassEx(&wc)); }
この関数に変更はありません。//ウィンドウの生成 BOOL InitInstance(HINSTANCE hInst, int nCmdShow) { HWND hWnd; hWnd = CreateWindow(szClassName, "猫でもわかるHTMLエディタ", //タイトルバーにこの名前が表示されます WS_OVERLAPPEDWINDOW, //ウィンドウの種類 CW_USEDEFAULT, //X座標 CW_USEDEFAULT, //Y座標 CW_USEDEFAULT, //幅 CW_USEDEFAULT, //高さ NULL, //親ウィンドウのハンドル、親を作るときはNULL NULL, //メニューハンドル、クラスメニューを使うときはNULL hInst, //インスタンスハンドル NULL); if (!hWnd) return FALSE; hParent = hWnd; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; }
巨大なウィンドウプロシージャです。//ウィンドウプロシージャ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { int id, nBtn, i; static HWND hEdit, hEdit_hide, hTool1, hTool2, hTool3, hToolMenuW, hRebar, hStatic, hStatus, hTip[3]; static HINSTANCE hInst; CREATESTRUCT *lpcs; char szWinTitle[64], szMenuName[32]; INITCOMMONCONTROLSEX ic; REBARINFO ri; REBARBANDINFO rbinfo; RECT rc, rc1, rc2; static int nClientX, nClientY, nRebarH, nStatusH; LPNMHDR lpnmhdr; int sb_size[3]; static HMENU hMenu; HMENU hToolMenu, hPopup; LPNMTOOLBAR lpnmTB; TPMPARAMS tpm; static COLORREF crTipText = RGB(255, 0, 0), crTipBk = RGB(255, 255, 255); NMREBARCHEVRON *lpnmchevron; int nHideBtn = 0; HMENU hPopMenu, hSubMenu; char szResourceName[32]; POINT pt; RECT rc1_scr, rc2_scr, rc3_scr; MYINITIALDATA myinit; switch (msg) { case WM_CREATE: memset(&myinit, 0, sizeof(MYINITIALDATA)); GetInitialSetting(&myinit); if (myinit.wx != 0 && myinit.wy != 0) { MoveWindow(hWnd, myinit.x, myinit.y, myinit.wx, myinit.wy, TRUE); } ic.dwSize = sizeof(INITCOMMONCONTROLSEX); ic.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES; InitCommonControlsEx(&ic); wsprintf(szWinTitle, lpszWinTitleOrg, "無題"); SetWindowText(hWnd, szWinTitle); lpcs = (CREATESTRUCT *)lp; hInst = lpcs->hInstance; hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN | ES_AUTOVSCROLL | ES_AUTOHSCROLL | WS_HSCROLL | WS_VSCROLL, 0, 0, 0, 0, hWnd, (HMENU)ID_EDIT, hInst, NULL); hEdit_g = hEdit; OrgEditProc = (WNDPROC)GetWindowLong(hEdit, GWL_WNDPROC); SetWindowLong(hEdit, GWL_WNDPROC, (LONG)NewEditProc); hEdit_hide = CreateWindow("EDIT", "", WS_CHILD, 0, 0, 0, 0, hEdit, (HMENU)ID_EDIT2, hInst, NULL); hStatic = CreateWindow("STATIC", "", WS_CHILD | WS_VISIBLE | SS_SUNKEN, 0, 0, 0, 0, hWnd, (HMENU)ID_STATIC, hInst, NULL); hRebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | RBS_BANDBORDERS | RBS_VARHEIGHT, 0, 0, 0, 0, hWnd, (HMENU)ID_REBAR, hInst, NULL); hToolMenuW = MakeMyToolbarMenu(hRebar); hMytoolMenu = hToolMenuW; hTool1 = MakeMyToolbar(hRebar, 3, tbButton1, ID_TOOL1); hTool2 = MakeMyToolbar(hRebar, 5, tbButton2, ID_TOOL2); hTool2_g = hTool2; hTool3 = MakeMyToolbar2(hRebar, 3, tbButton3, ID_TOOL3, IDR_TOOLBAR3, IDR_TOOLBAR3X); hStatus = CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", hWnd, ID_STATUS); memset(&ri, 0, sizeof(REBARINFO)); ri.cbSize = sizeof(REBARINFO); ri.fMask = 0; ri.himl = NULL; SendMessage(hRebar, RB_SETBARINFO, 0, (LPARAM)&ri); memset(&rbinfo, 0, sizeof(REBARBANDINFO)); rbinfo.cbSize = sizeof(REBARBANDINFO); rbinfo.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_IDEALSIZE; rbinfo.fStyle = RBBS_CHILDEDGE | RBBS_USECHEVRON; rbinfo.hwndChild = hToolMenuW; rbinfo.cxMinChild = 0; rbinfo.cyMinChild = 22; rbinfo.cxIdeal = 280; rbinfo.cx = 280; SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbinfo); rbinfo.fStyle = RBBS_CHILDEDGE | RBBS_USECHEVRON | RBBS_BREAK; rbinfo.hwndChild = hTool1; rbinfo.cxMinChild = 0; rbinfo.cxIdeal = 69; rbinfo.cx = 85; SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbinfo); rbinfo.fStyle = RBBS_CHILDEDGE | RBBS_USECHEVRON; GetWindowRect(hRebar, &rc); rbinfo.hwndChild = hTool2; rbinfo.cxMinChild = 0; rbinfo.cxIdeal = 115; rbinfo.cx = 131; SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbinfo); rbinfo.hwndChild = hTool3; rbinfo.cxMinChild = 0; rbinfo.cx = 79; rbinfo.cxIdeal = 95; SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbinfo); hTip[0] = MakeMyToolTip(hWnd, hTool1, 0, 2, tbButton1, szTipText1); hTip[1] = MakeMyToolTip(hWnd, hTool2, 0, 4, tbButton2, szTipText2); hTip[2] = MakeMyToolTip(hWnd, hTool3, 0, 2, tbButton3, szTipText3); if (myinit.crTipText != 0 && myinit.crTipText != 0) { crTipText = myinit.crTipText; crTipBk = myinit.crTipBackground; for (i = 0; i < 3; i++) { SendMessage(hTip[i], TTM_SETTIPBKCOLOR, (WPARAM)crTipBk, 0); SendMessage(hTip[i], TTM_SETTIPTEXTCOLOR, (WPARAM)crTipText, 0); } } SendMessage(hEdit, MY_MSG, 0, (LPARAM)hTool2); hHook = SetWindowsHookEx(WH_KEYBOARD, KbdHook, (HINSTANCE)hInst, 0); if (hHook == NULL) MessageBox(hWnd, "フック失敗", "Error", MB_OK); break; case WM_SIZE: nClientX = LOWORD(lp); nClientY = HIWORD(lp); MoveWindow(hStatic , 0, 0, nClientX, 2, TRUE); GetWindowRect(hRebar, &rc); nRebarH = rc.bottom - rc.top; GetWindowRect(hStatus, &rc); nStatusH = rc.bottom - rc.top; SendMessage(hRebar, WM_SIZE, wp, lp); sb_size[2] = nClientX; sb_size[1] = nClientX - 200; sb_size[0] = 300; SendMessage(hStatus, SB_SETPARTS, (WPARAM)3, (LPARAM)sb_size); SendMessage(hStatus, WM_SIZE, wp, lp); MoveWindow(hEdit, 0, nRebarH + 2, LOWORD(lp), HIWORD(lp) - (nRebarH + 2 + nStatusH), TRUE); SetFocus(hEdit); break; case WM_MENUSELECT: switch (LOWORD(wp)) { case IDM_NEW: MySetStatusText(hStatus, 0, szTipText1[0]); break; case IDM_OPEN: MySetStatusText(hStatus, 0, szTipText1[1]); break; case IDM_SAVE: MySetStatusText(hStatus, 0, szTipText1[2]); break; case IDM_COPY: MySetStatusText(hStatus, 0, szTipText2[0]); break; case IDM_CUT: MySetStatusText(hStatus, 0, szTipText2[1]); break; case IDM_PASTE: MySetStatusText(hStatus, 0, szTipText2[2]); break; case IDM_DELETE: MySetStatusText(hStatus, 0, szTipText2[3]); break; case IDM_UNDO: MySetStatusText(hStatus, 0, szTipText2[4]); break; case IDM_BASICINPUT: MySetStatusText(hStatus, 0, szTipText3[0]); break; case IDM_SCRIPT: MySetStatusText(hStatus, 0, szTipText3[1]); break; case IDM_SAVEAS: MySetStatusText(hStatus, 0, "名前を付けて保存します"); break; case IDM_END: MySetStatusText(hStatus, 0, "このアプリケーションを終了します"); break; case IDM_ALL: MySetStatusText(hStatus, 0, "すべてを選択状態にします"); break; case IDM_P: MySetStatusText(hStatus, 0, "<P>タグを挿入します"); break; case IDM_BR: MySetStatusText(hStatus, 0, "<BR>タグを挿入します"); break; case IDM_H: MySetStatusText(hStatus, 0, "<H>タグを挿入します"); break; case IDM_IMAGE: MySetStatusText(hStatus, 0, "<IMG>タグを挿入します"); break; case IDM_A: MySetStatusText(hStatus, 0, "<A HREF>タグを挿入します"); break; case IDM_TABLE: MySetStatusText(hStatus, 0, "<TABLE>タグを挿入します"); break; case IDM_FORM: MySetStatusText(hStatus, 0, "<FORM>タグを挿入します"); break; case IDM_INPUT: MySetStatusText(hStatus, 0, "<INPUT>タグを挿入します"); break; case IDM_BROWSER: MySetStatusText(hStatus, 0, "作成したHTML文書をブラウザで表示します"); break; case IDM_TIPTXTCOLOR: MySetStatusText(hStatus, 0, "ツールチップの文字色を設定します"); break; case IDM_TIPBKCOLOR: MySetStatusText(hStatus, 0, "ツールチップの背景色を設定します"); break; default: MySetStatusText(hStatus, 0, ""); break; } break; case WM_EXITMENULOOP: MySetStatusText(hStatus, 0, ""); SendMessage(hMytoolMenu, TB_SETHOTITEM, (WPARAM)-1, 0); break; case WM_NOTIFY: lpnmhdr = (LPNMHDR)lp; if (lpnmhdr->code == TTN_POP) { MySetStatusText(hStatus, 0, ""); return 0; } switch (wp) { case IDM_NEW: MySetStatusText(hStatus, 0, szTipText1[0]); break; case IDM_OPEN: MySetStatusText(hStatus, 0, szTipText1[1]); break; case IDM_SAVE: MySetStatusText(hStatus, 0, szTipText1[2]); break; case IDM_COPY: MySetStatusText(hStatus, 0, szTipText2[0]); break; case IDM_CUT: MySetStatusText(hStatus, 0, szTipText2[1]); break; case IDM_PASTE: MySetStatusText(hStatus, 0, szTipText2[2]); break; case IDM_DELETE: MySetStatusText(hStatus, 0, szTipText2[3]); break; case IDM_UNDO: MySetStatusText(hStatus, 0, szTipText2[4]); break; case IDM_BASICINPUT: MySetStatusText(hStatus, 0, szTipText3[0]); break; case IDM_SCRIPT: MySetStatusText(hStatus, 0, szTipText3[1]); break; case IDM_TAG: MySetStatusText(hStatus, 0, szTipText3[2]); break; case ID_TOOL3: if (lpnmhdr->hwndFrom == hTool3 && lpnmhdr->code == TBN_DROPDOWN) { lpnmTB = (LPNMTOOLBAR)lp; SendMessage(hTool3, TB_GETRECT, (WPARAM)lpnmTB->iItem, (LPARAM)&rc); MapWindowPoints(hTool3, HWND_DESKTOP, (LPPOINT)&rc, 2); tpm.cbSize = sizeof(TPMPARAMS); tpm.rcExclude.top = rc.top; tpm.rcExclude.left = rc.left; tpm.rcExclude.bottom = rc.bottom; tpm.rcExclude.right = rc.right; switch (lpnmTB->iItem) { case IDM_TAG: lstrcpy(szMenuName, "INSERT"); break; default: return (DefWindowProc(hWnd, msg, wp, lp)); } hToolMenu = LoadMenu(hInst, szMenuName); hPopup = GetSubMenu(hToolMenu, 0); TrackPopupMenuEx(hPopup, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL, rc.left, rc.bottom, hWnd, &tpm); DestroyMenu(hToolMenu); } break; case ID_REBAR: switch (lpnmhdr->code) { case RBN_HEIGHTCHANGE: GetWindowRect(hRebar, &rc); nRebarH = rc.bottom - rc.top; MoveWindow(hEdit, 0, nRebarH + 2, nClientX, nClientY - nRebarH - 2 - nStatusH, TRUE); break; case RBN_CHEVRONPUSHED: lpnmchevron = (NMREBARCHEVRON *)lp; if (SendMessage(hRebar, RB_GETRECT, (WPARAM)lpnmchevron->uBand, (LPARAM)&rc1) == 0) { MessageBox(hWnd, "RB_GETRECT ERROR", "OK", MB_OK); return FALSE; } pt.x = rc1.left; pt.y = rc1.top; ClientToScreen(hRebar, &pt); rc1_scr.left = pt.x; rc1_scr.top = pt.y; pt.x = rc1.right; pt.y = rc1.bottom; ClientToScreen(hRebar, &pt); rc1_scr.right = pt.x; rc1_scr.bottom = pt.y; memset(&rbinfo, 0, sizeof(REBARBANDINFO)); rbinfo.cbSize = sizeof(REBARBANDINFO); rbinfo.fMask = RBBIM_CHILD; if (SendMessage(hRebar, RB_GETBANDINFO, (WPARAM)lpnmchevron->uBand, (LPARAM)&rbinfo) == 0) MessageBox(hWnd, "Error RB_GETBANDINFO", "Error", MB_OK); nBtn = SendMessage(rbinfo.hwndChild, TB_BUTTONCOUNT, 0, 0); for (i = 0; i < nBtn; i++) { SendMessage(rbinfo.hwndChild, TB_GETITEMRECT, (WPARAM)i, (LPARAM)&rc2); pt.x = rc2.left; pt.y = rc2.top; ClientToScreen(rbinfo.hwndChild, &pt); rc2_scr.left = pt.x; rc2_scr.top = pt.y; pt.x = rc2.right; pt.y = rc2.bottom; ClientToScreen(rbinfo.hwndChild, &pt); rc2_scr.right = pt.x; rc2_scr.bottom = pt.y; IntersectRect(&rc3_scr, &rc2_scr, &rc1_scr); if (!EqualRect(&rc2_scr, &rc3_scr)) { nHideBtn = nBtn - i; break; } } if (rbinfo.hwndChild == hToolMenuW) { strcpy(szResourceName, "MYMENU2"); } else if (rbinfo.hwndChild == hTool1) { strcpy(szResourceName, "FILE"); } else if (rbinfo.hwndChild == hTool2) { strcpy(szResourceName, "EDIT"); } else if (rbinfo.hwndChild == hTool3) { strcpy(szResourceName, "INSERT2"); } else { MessageBox(hWnd, "Error", "Error", MB_OK); return FALSE; } hPopMenu = LoadMenu(hInst, szResourceName); if (hPopMenu == NULL) { MessageBox(hWnd, "LoadMenu Error", "Error", MB_OK); break; } hSubMenu = GetSubMenu(hPopMenu, 0); if (nHideBtn == 0) nHideBtn = 1; for (i = 0; i < nBtn - nHideBtn; i++) { if (DeleteMenu(hSubMenu, 0, MF_BYPOSITION) == 0) { MessageBox(hWnd, "DeleteMenu Error", "Error", MB_OK); return 0; } } CheckMyMenu(hPopMenu, hEdit, hTool2); TrackPopupMenu(hSubMenu, TPM_LEFTALIGN, rc1_scr.right-10, rc1_scr.bottom, 0, hWnd, NULL); DestroyMenu(hPopMenu); break; default: return DefWindowProc(hWnd, msg, wp, lp); } break; } break; case WM_COMMAND: switch (LOWORD(wp)) { case IDM_END: SendMessage(hWnd, WM_CLOSE, 0, 0); break; case IDM_BASICINPUT: if (MyBasicInput(hEdit) == IDCANCEL) break; id = MessageBox(hWnd, "現在のソースファイルが置き換わりますがよろしいですか", "注意", MB_YESNO | MB_ICONQUESTION); if (id == IDNO) break; if (MySetHTML(hEdit, hEdit_hide)) MySetStatusText(hStatus, 0, "基本項目を入力しました"); break; case IDM_SAVEAS: MySaveAs(hEdit); wsprintf(szWinTitle, lpszWinTitleOrg, szFileTitle); SetWindowText(hWnd, szWinTitle); break; case IDM_NEW: if (SendMessage(hEdit, EM_GETMODIFY, 0, 0)) { id = MessageBox(hWnd, "変更を保存しますか", "注意", MB_YESNO | MB_ICONQUESTION); if (id == IDYES) MySave(hEdit); } SendMessage(hEdit, EM_SETSEL, (WPARAM)0, (LPARAM)-1); SendMessage(hEdit, WM_CLEAR, 0, 0); strcpy(szFileName, ""); strcpy(szFileTitle, ""); wsprintf(szWinTitle, lpszWinTitleOrg, "無題"); SetWindowText(hWnd, szWinTitle); break; case IDM_SAVE: id = MessageBox(hWnd, "上書きしてもよろしいですか", "上書き保存", MB_YESNO | MB_ICONQUESTION); if (id == IDYES) { MySave(hEdit); wsprintf(szWinTitle, lpszWinTitleOrg, szFileTitle); SetWindowText(hWnd, szWinTitle); } break; case IDM_P: MyInsertTag(hEdit, hEdit_hide, "<P>"); MySetStatusText(hStatus, 0, "<P>タグを挿入しました"); break; case IDM_BR: MyInsertTag(hEdit, hEdit_hide, "<BR>"); MySetStatusText(hStatus, 0, "<BR>タグを挿入しました"); break; case IDM_H: if (MyInsertH(hEdit, hEdit_hide)) MySetStatusText(hStatus, 0, "<H>タグを挿入しました");; break; case IDM_IMAGE: if (MyInsertIMG(hEdit, hEdit_hide)) MySetStatusText(hStatus, 0, "イメージを挿入しました"); break; case IDM_BROWSER: if (strcmp(szFileName, "") == 0) { MessageBox(hWnd, "まだHTMLファイルが保存されていません", "Error", MB_OK); break; } if (ShellExecute(NULL, "open", szFileName, NULL, NULL, SW_SHOWNORMAL) > (HINSTANCE)32) { MySetStatusText(hStatus, 0, "ブラウザが起動しました"); } else { MySetStatusText(hStatus, 0, "ブラウザの起動に失敗"); } return 0; case IDM_A: if (MyInsertA(hEdit, hEdit_hide)) MySetStatusText(hStatus, 0, "<A>タグを挿入しました"); break; case IDM_TABLE: if (MyInsertTable(hEdit, hEdit_hide)) MySetStatusText(hStatus, 0, "テーブルを挿入しました"); break; case IDM_FORM: if (MyInsertForm(hEdit, hEdit_hide)) MySetStatusText(hStatus, 0, "<FORM>タグを挿入しました"); break; case IDM_INPUT: if (MyInsertInput(hEdit, hEdit_hide)) MySetStatusText(hStatus, 0, "<INPUT>タグを挿入しました"); break; case IDM_SCRIPT: if (MyInsertScript(hEdit, hEdit_hide)) MySetStatusText(hStatus, 0, "<SCRIPT>タグを挿入しました"); break; case IDM_OPEN: MyOpen(hEdit, hEdit_hide); break; case IDM_COPY: SendMessage(hEdit, WM_COPY, 0, 0); break; case IDM_CUT: SendMessage(hEdit, WM_CUT, 0, 0); break; case IDM_PASTE: SendMessage(hEdit, WM_PASTE, 0, 0); break; case IDM_UNDO: SendMessage(hEdit, WM_UNDO, 0, 0); break; case IDM_DELETE: SendMessage(hEdit, WM_CLEAR, 0, 0); break; case IDM_ALL: SendMessage(hEdit, EM_SETSEL, (WPARAM)0, (LPARAM)-1); break; case IDM_TIPTXTCOLOR: SetTipColor(hEdit, hTip, &crTipText, 3); break; case IDM_TIPBKCOLOR: SetTipBkColor(hEdit, hTip, &crTipBk, 3); break; //メニュー型ツールバー case IDM_FILE: ShowMyPopMenu(hWnd, hToolMenuW, "MYMENU", 0, hEdit, hTool2); break; case IDM_EDIT: ShowMyPopMenu(hWnd, hToolMenuW, "MYMENU", 1, hEdit, hTool2); break; case IDM_INSERT: ShowMyPopMenu(hWnd, hToolMenuW, "MYMENU", 2, hEdit, hTool2); break; case IDM_BRVIEW: ShowMyPopMenu(hWnd, hToolMenuW, "MYMENU", 3, hEdit, hTool2); break; case IDM_OPTION: ShowMyPopMenu(hWnd, hToolMenuW, "MYMENU", 4, hEdit, hTool2); break; //画像ファイルGIFの呼び出し・出力 case IDM_WHAT: MyCreateFileFromResource(hEdit, hEdit_hide, "WHAT", "GIF", "what.gif"); break; case IDM_MAILTO: MyCreateFileFromResource(hEdit, hEdit_hide, "MAIL", "GIF", "mail.gif"); break; case IDM_HOME: MyCreateFileFromResource(hEdit, hEdit_hide, "HOME", "GIF", "home.gif"); break; case IDM_INDEX: MyCreateFileFromResource(hEdit, hEdit_hide, "INDEX", "GIF", "index.gif"); break; case IDM_BACK: MyCreateFileFromResource(hEdit, hEdit_hide, "BACK", "GIF", "back.gif"); break; case IDM_CONTENTS: MyCreateFileFromResource(hEdit, hEdit_hide, "CONTENTS", "GIF", "contents.gif"); break; //ダイレクト・アニメーション case IDM_DIRECTANI_TEXT: MyDirectAniText(hEdit, hEdit_hide); break; case IDM_DIRECTANI_PATH: MyDirectAniPath(hEdit, hEdit_hide); break; } CheckMyMenu(hMenu, hEdit, hTool2); SetFocus(hEdit); break; case WM_CLOSE: id = MessageBox(hWnd, "終了してもよいですか", "終了確認", MB_YESNO | MB_ICONQUESTION); if (id == IDYES) { if (SendMessage(hEdit, EM_GETMODIFY, 0, 0)) { id = MessageBox(hWnd, "変更を保存しますか", "保存", MB_YESNO | MB_ICONQUESTION); if (id == IDYES) MySave(hEdit); } UnhookWindowsHookEx(hHook); GetWindowRect(hWnd, &rc); myinit.x = rc.left; myinit.y = rc.top; myinit.wx = rc.right - rc.left; myinit.wy = rc.bottom - rc.top; myinit.crTipText = crTipText; myinit.crTipBackground = crTipBk; SetInitialSetting(&myinit); SetWindowLong(hEdit, GWL_WNDPROC, (LONG)OrgEditProc); ImageList_Destroy(hImage); DestroyWindow(hTip[0]); DestroyWindow(hTip[1]); DestroyWindow(hTip[2]); DestroyWindow(hTool1); DestroyWindow(hTool2); DestroyWindow(hTool3); DestroyWindow(hRebar); DestroyWindow(hStatus); DestroyWindow(hStatic); DestroyWindow(hEdit_hide); DestroyWindow(hEdit); DestroyWindow(hWnd); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return (DefWindowProc(hWnd, msg, wp, lp)); } return 0; }
LoadMenu関数の第1引数をhInstに戻しました。
メニューの「挿入」「ダイレクト・アニメーション」「パスコントロール」が 選択されるとMyDirectAniPath関数を呼びます。
終了時のFreeLibrary関数は不要となったので削除しました。
この関数に変更はありません。BOOL MySetHTML(HWND hEdit, HWND hEdit_hide) { char szBuf[1024*10]; strcpy(szBuf, lpszHead); strcat(szBuf, szTitle); strcat(szBuf, lpszBody1); strcat(szBuf, szBody2); strcat(szBuf, lpszBody3); strcat(szBuf, lpszAddress); strcat(szBuf, lpszMailto); strcat(szBuf, szEMail); strcat(szBuf, lpszMailEnd); strcat(szBuf, szAuthor); strcat(szBuf, lpszCloseA); strcat(szBuf, lpszEnd); SetWindowText(hEdit, ""); MyInsertTag(hEdit, hEdit_hide, szBuf); return TRUE; }
DialogBoxの第1引数をhInstに戻しました。int MyBasicInput(HWND hEdit) { int id; id = DialogBox(hInst, "MYBASICINPUT", hEdit, (DLGPROC)MyBasicInputProc); return id; }
これらの関数に変更はありません。LRESULT CALLBACK MyBasicInputProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp) { static HWND hTitle, hName, hEMail, hWallPaper, hColor, hNotSpecify; static int nBack; //0:nothing 1:Color 2:WallPaper switch (msg) { case WM_INITDIALOG: strcpy(szBody2, ""); hTitle = GetDlgItem(hDlg, IDC_EDIT1); hName = GetDlgItem(hDlg, IDC_EDIT2); hEMail = GetDlgItem(hDlg, IDC_EDIT3); hWallPaper = GetDlgItem(hDlg, IDC_RADIO2); hColor = GetDlgItem(hDlg, IDC_RADIO1); hNotSpecify = GetDlgItem(hDlg, IDC_RADIO3); SetWindowText(hTitle, szTitle); SetWindowText(hName, szAuthor); SetWindowText(hEMail, szEMail); SetFocus(hTitle); switch (nBack) { case 0: Button_SetCheck(hNotSpecify, BST_CHECKED); break; case 1: Button_SetCheck(hColor, BST_CHECKED); break; case 2: Button_SetCheck(hWallPaper, BST_CHECKED); break; default: MessageBox(hDlg, "内部エラーです", "Error", MB_OK); break; } return TRUE; case WM_COMMAND: switch (LOWORD(wp)) { case IDOK: Edit_GetText(hTitle, szTitle, sizeof(szTitle)); Edit_GetText(hName, szAuthor, sizeof(szAuthor)); Edit_GetText(hEMail, szEMail, sizeof(szEMail)); if (Button_GetCheck(hColor) == BST_CHECKED) { if (!MyGetBodyColor(hDlg)) break; nBack = 1; } if (Button_GetCheck(hWallPaper) == BST_CHECKED) { if (!MyGetWallPaper(hDlg)) break; nBack = 2; } if (Button_GetCheck(hNotSpecify) == BST_CHECKED) { nBack = 0; } EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; } return FALSE; } return FALSE; } BOOL MySaveAs(HWND hEdit) { OPENFILENAME ofn; HANDLE hFile; char szBuf[MY_BUF_SIZE]; DWORD dwWritten; memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hEdit; ofn.lpstrFilter = "htmlファイル\0*.htm;*.html\0All Files(*.*)\0*.*\0\0"; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.lpstrDefExt = "html"; ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; if (GetSaveFileName(&ofn)) { hFile = CreateFile(szFileName, GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { MessageBox(hEdit, "ファイルのオープンに失敗しました", "Error", MB_OK); return FALSE; } Edit_GetText(hEdit, szBuf, MY_BUF_SIZE); WriteFile(hFile, szBuf, strlen(szBuf), &dwWritten, NULL); SetEndOfFile(hFile); CloseHandle(hFile); SendMessage(hEdit, EM_SETMODIFY, (WPARAM)FALSE, 0); } return TRUE; } BOOL MySave(HWND hEdit) { HANDLE hFile; char szBuf[MY_BUF_SIZE]; DWORD dwWritten; if (strcmp(szFileName, "") == 0) { MessageBox(hEdit, "まず名前を付けて保存してください。", "確認", MB_OK); MySaveAs(hEdit); return TRUE; } Edit_GetText(hEdit, szBuf, MY_BUF_SIZE); hFile = CreateFile(szFileName, GENERIC_WRITE, 0, 0, TRUNCATE_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { MessageBox(hEdit, "ファイルをオープンできません", "Error", MB_OK); return FALSE; } WriteFile(hFile, szBuf, strlen(szBuf), &dwWritten, NULL); if (strlen(szBuf) != dwWritten) { MessageBox(hEdit, "書き込みに失敗しました", "Error", MB_OK); CloseHandle(hFile); return FALSE; } CloseHandle(hFile); SendMessage(hEdit, EM_SETMODIFY, (WPARAM)FALSE, 0); return TRUE; } BOOL MyInsertTag(HWND hEdit1, HWND hEdit2, char *lpszTag) { SetWindowText(hEdit2, lpszTag); SendMessage(hEdit2, EM_SETSEL, (WPARAM)0, (LPARAM)-1); SendMessage(hEdit2, WM_COPY, 0, 0); SendMessage(hEdit1, WM_PASTE, 0, 0); return TRUE; }
DialogBoxParamの第1引数がhInstになりました。BOOL MyInsertH(HWND hEdit, HWND hEdit_hide) { MYHTAG myh; char szBuf[512]; if (DialogBoxParam(hInst, "MYHTAG", hEdit, (DLGPROC)MyHProc, (LPARAM)&myh) == IDCANCEL) return FALSE; strcpy(szBuf, "<H"); strcat(szBuf, myh.szTagNo); strcat(szBuf, ">"); strcat(szBuf, myh.szContents); strcat(szBuf, "</H"); strcat(szBuf, myh.szTagNo); strcat(szBuf, ">"); MyInsertTag(hEdit, hEdit_hide, szBuf); return TRUE; }
この関数に変更はありません。LRESULT CALLBACK MyHProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp) { static HWND hCombo, hEditContents; static LPMYHTAG lpmyh; switch (msg) { case WM_INITDIALOG: lpmyh = (LPMYHTAG)lp; hCombo = GetDlgItem(hDlg, IDC_COMBO1); hEditContents = GetDlgItem(hDlg, IDC_EDIT1); ComboBox_AddString(hCombo, "1"); ComboBox_AddString(hCombo, "2"); ComboBox_AddString(hCombo, "3"); ComboBox_AddString(hCombo, "4"); ComboBox_AddString(hCombo, "5"); ComboBox_AddString(hCombo, "6"); return TRUE; case WM_COMMAND: switch (LOWORD(wp)) { case IDOK: ComboBox_GetText(hCombo, lpmyh->szTagNo, sizeof(lpmyh->szTagNo)); Edit_GetText(hEditContents, lpmyh->szContents, sizeof(lpmyh->szContents)); EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; case IDC_COMBO1: if (HIWORD(wp) == CBN_SELCHANGE) { SetFocus(hEditContents); return TRUE; } else { return FALSE; } } return FALSE; } return FALSE; }
これも、hInstDllがhInstに戻りました。BOOL MyInsertIMG(HWND hEdit, HWND hEdit_hide) { MYIMGTAG myimg; char szBuf[1024]; if (DialogBoxParam(hInst, "MYIMGTAG", hEdit, (DLGPROC)MyImgProc, (LPARAM)&myimg) == IDCANCEL) return FALSE; strcpy(szBuf, "<IMG SRC=\""); if (myimg.bPath) strcat(szBuf, myimg.szPath); strcat(szBuf, myimg.szFileName); strcat(szBuf, "\">"); MyInsertTag(hEdit, hEdit_hide, szBuf); return TRUE; }
これらの関数に変更はありません。LRESULT CALLBACK MyImgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp) { static HWND hButton, hPath, hFile, hCheck, hImg; static LPMYIMGTAG lpimg; static BOOL bImg, bPath; switch (msg) { case WM_INITDIALOG: lpimg = (LPMYIMGTAG)lp; hButton = GetDlgItem(hDlg, IDC_BUTTON1); hCheck = GetDlgItem(hDlg, IDC_CHECK1); hPath = GetDlgItem(hDlg, IDC_EDIT1); hFile = GetDlgItem(hDlg, IDC_EDIT2); hImg = GetDlgItem(hDlg, IDC_CHECK2); if (bImg) Button_SetCheck(hImg, BST_CHECKED); else Button_SetCheck(hImg, BST_UNCHECKED); if (bPath) { EnableWindow(hPath, TRUE); Button_SetCheck(hCheck, BST_CHECKED); } else { EnableWindow(hPath, FALSE); Button_SetCheck(hCheck, BST_UNCHECKED); } return TRUE; case WM_COMMAND: switch (LOWORD(wp)) { case IDOK: Edit_GetText(hFile, lpimg->szFileName, MAX_PATH); if (Button_GetCheck(hCheck) == BST_CHECKED) { Edit_GetText(hPath, lpimg->szPath, MAX_PATH); lpimg->bPath = TRUE; } else { strcpy(lpimg->szPath, ""); lpimg->bPath = FALSE; } EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; case IDC_CHECK1: if (Button_GetCheck(hCheck) == BST_CHECKED) { EnableWindow(hPath, TRUE); SetFocus(hPath); bPath = TRUE; } else { EnableWindow(hPath, FALSE); bPath = FALSE; } return TRUE; case IDC_BUTTON1: MyGetFileTitle(hDlg, hFile, bImg); return TRUE; case IDC_CHECK2: if (Button_GetCheck(hImg) == BST_CHECKED) bImg = TRUE; else bImg = FALSE; return TRUE; } return FALSE; } return FALSE; } BOOL MyGetFileTitle(HWND hDlg, HWND hFile, BOOL bImg) { OPENFILENAME ofn; char szFileTitle[MAX_PATH], szFileName[MAX_PATH]; szFileTitle[0] = '\0'; szFileName[0] = '\0'; memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hDlg; ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.lpstrFilter = "gifファイル\0*.gif\0jpegファイル\0*.jpg;*.jpeg\0すべてのファイル\0*.*\0\0"; ofn.Flags = OFN_HIDEREADONLY; if (!GetOpenFileName(&ofn)) return FALSE; SetWindowText(hFile, szFileTitle); if (bImg) { if (ShellExecute(hDlg, "open", szFileName, NULL, NULL, SW_SHOWNORMAL) <= (HINSTANCE)32) { MessageBox(hDlg, "画像を表示できません", "Error", MB_OK); return FALSE; } } return TRUE; } BOOL MyGetBodyColor(HWND hDlg) { CHOOSECOLOR cc; static COLORREF crResult = RGB(0, 0, 0); static DWORD dwCustColor[16]; char szRed[8], szGreen[8], szBlue[8]; 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)) return FALSE; crResult = cc.rgbResult; wsprintf(szRed, "%02X", GetRValue(crResult)); wsprintf(szGreen, "%02X", GetGValue(crResult)); wsprintf(szBlue, "%02X", GetBValue(crResult)); strcpy(szBody2, " BGCOLOR=\"#"); strcat(szBody2, szRed); strcat(szBody2, szGreen); strcat(szBody2, szBlue); strcat(szBody2, "\""); return TRUE; }
同じ変更です。BOOL MyGetWallPaper(HWND hDlg) { MYIMGTAG myimg; if (DialogBoxParam(hInst, "MYIMGTAG", hDlg, (DLGPROC)MyImgProc, (LPARAM)&myimg) == IDCANCEL) return FALSE; strcpy(szBody2, " BACKGROUND=\""); if (myimg.bPath) strcat(szBody2, myimg.szPath); strcat(szBody2, myimg.szFileName); strcat(szBody2, "\""); return TRUE; }
これも、hInstDllがhInstに戻りました。BOOL MyInsertA(HWND hEdit, HWND hEdit_hide) { MYIMGTAG myatag; char szBuf[1024]; if (DialogBoxParam(hInst, "MYIMGTAG", hEdit, (DLGPROC)MyAProc, (LPARAM)&myatag) == IDCANCEL) return FALSE; strcpy(szBuf, "<A HREF=\""); if (myatag.bPath) strcat(szBuf, myatag.szPath); strcat(szBuf, myatag.szFileName); strcat(szBuf, "\"></A>"); MyInsertTag(hEdit, hEdit_hide, szBuf); return TRUE; }
これらの関数に変更はありません。LRESULT CALLBACK MyAProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp) { static HWND hPath, hFile, hCheck1, hCheck2; static LPMYIMGTAG lpatag; static BOOL bPath, bKakunin; switch (msg) { case WM_INITDIALOG: lpatag = (LPMYIMGTAG)lp; hPath = GetDlgItem(hDlg, IDC_EDIT1); hFile = GetDlgItem(hDlg, IDC_EDIT2); hCheck1 = GetDlgItem(hDlg, IDC_CHECK1); hCheck2 = GetDlgItem(hDlg, IDC_CHECK2); SetWindowText(hDlg, "A HREFの挿入"); SetWindowText(hCheck2, "ファイルの確認"); if (bKakunin) Button_SetCheck(hCheck2, BST_CHECKED); else Button_SetCheck(hCheck2, BST_UNCHECKED); if (bPath) { EnableWindow(hPath, TRUE); Button_SetCheck(hCheck1, BST_CHECKED); } else { EnableWindow(hPath, FALSE); Button_SetCheck(hCheck1, BST_UNCHECKED); } return TRUE; case WM_COMMAND: switch (LOWORD(wp)) { case IDOK: Edit_GetText(hFile, lpatag->szFileName, MAX_PATH); if (bPath) { Edit_GetText(hPath, lpatag->szPath, MAX_PATH); lpatag->bPath = TRUE; } else { strcpy(lpatag->szPath, ""); lpatag->bPath = FALSE; } EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; case IDC_CHECK1: if (Button_GetCheck(hCheck1) == BST_CHECKED) { EnableWindow(hPath, TRUE); bPath = TRUE; } else { EnableWindow(hPath, FALSE); bPath = FALSE; } return TRUE; case IDC_CHECK2: if (Button_GetCheck(hCheck2) == BST_CHECKED) bKakunin = TRUE; else bKakunin = FALSE; return TRUE; case IDC_BUTTON1: MyGetHREFFile(hDlg, hFile, bKakunin); return TRUE; } return FALSE; } return FALSE; } BOOL MyGetHREFFile(HWND hDlg, HWND hFile, BOOL bKakunin) { OPENFILENAME ofn; char szFileTitle[MAX_PATH], szFileName[MAX_PATH]; szFileTitle[0] = '\0'; szFileName[0] = '\0'; memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hDlg; ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.lpstrFilter = "HTMLファイル\0*.htm;*.html\0すべてのファイル\0*.*\0\0"; ofn.Flags = OFN_HIDEREADONLY; if (!GetOpenFileName(&ofn)) return FALSE; SetWindowText(hFile, szFileTitle); if (bKakunin) { if (ShellExecute(hDlg, "edit", szFileName, NULL, NULL, SW_SHOWNORMAL) <= (HINSTANCE)32) { MessageBox(hDlg, "ファイルを表示できません", "Error", MB_OK); return FALSE; } } return TRUE; }
これも、DialogBoxParamの第1引数がhInstDllからhInstに変更になったのみです。BOOL MyInsertTable(HWND hEdit, HWND hEdit_hide) { MYTABLETAG mytable; char szBuf[1024 * 2]; int i, j, nRow, nCol; if (DialogBoxParam(hInst, "MYTABLETAG", hEdit, (DLGPROC)MyTableProc, (LPARAM)&mytable) == IDCANCEL) return FALSE; nRow = atoi(mytable.szRow); nCol = atoi(mytable.szColumn); strcpy(szBuf, "<TABLE"); if (mytable.bBorder) { strcat(szBuf, " BORDER=\""); strcat(szBuf, mytable.szBorder); strcat(szBuf, "\""); } strcat(szBuf, ">\r\n"); if (mytable.bTitle) { strcat(szBuf, "<CAPTION ALIGN=\""); strcat(szBuf, mytable.szTitleAlign); strcat(szBuf, "\">"); strcat(szBuf, mytable.szTitle); strcat(szBuf, "</CAPTION>\r\n"); } for (j = 1; j <= nRow; j++) { for (i = 1; i <= nCol; i++) { strcat(szBuf, "<TD></TD>"); } if (j != nRow) strcat(szBuf, "<TR>\r\n"); } strcat(szBuf, "\r\n</TABLE>"); MyInsertTag(hEdit, hEdit_hide, szBuf); return TRUE; }
この部分に変更はありません。LRESULT CALLBACK MyTableProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp) { static HWND hRow, hCol, hBorderCheck, hBorderEdit, hCapCheck, hCapCombo, hCapEdit; static LPMYTABLETAG lpmytable; char szNum[][4] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}; int i; static BOOL bBorder, bCaption; switch (msg) { case WM_INITDIALOG: lpmytable = (LPMYTABLETAG)lp; hRow = GetDlgItem(hDlg, IDC_COMBO1); hCol = GetDlgItem(hDlg, IDC_COMBO2); hBorderCheck = GetDlgItem(hDlg, IDC_CHECK1); hCapCheck = GetDlgItem(hDlg, IDC_CHECK2); hBorderEdit = GetDlgItem(hDlg, IDC_EDIT1); hCapCombo = GetDlgItem(hDlg, IDC_COMBO3); hCapEdit = GetDlgItem(hDlg, IDC_EDIT2); for (i = 0; i < 10; i++) { ComboBox_AddString(hRow, szNum[i]); ComboBox_AddString(hCol, szNum[i]); } ComboBox_SetText(hRow, "1"); ComboBox_SetText(hCol, "1"); ComboBox_AddString(hCapCombo, "top"); ComboBox_AddString(hCapCombo, "bottom"); if (bBorder) { Button_SetCheck(hBorderCheck, BST_CHECKED); ShowWindow(hBorderEdit, SW_SHOW); } else { Button_SetCheck(hBorderCheck, BST_UNCHECKED); ShowWindow(hBorderEdit, SW_HIDE); } if (bCaption) { Button_SetCheck(hCapCheck, BST_CHECKED); ShowWindow(hCapCombo, SW_SHOW); ShowWindow(hCapEdit, SW_SHOW); } else { Button_SetCheck(hCapCheck, BST_UNCHECKED); ShowWindow(hCapCombo, SW_HIDE); ShowWindow(hCapEdit, SW_HIDE); } return TRUE; case WM_COMMAND: switch (LOWORD(wp)) { case IDOK: ComboBox_GetText(hRow, lpmytable->szRow, sizeof(lpmytable->szRow)); ComboBox_GetText(hCol, lpmytable->szColumn, sizeof(lpmytable->szColumn)); if (bBorder) { Edit_GetText(hBorderEdit, lpmytable->szBorder, sizeof(lpmytable->szBorder)); lpmytable->bBorder = TRUE; } else { strcpy(lpmytable->szBorder, ""); lpmytable->bBorder = FALSE; } if (bCaption) { ComboBox_GetText(hCapCombo, lpmytable->szTitleAlign, sizeof(lpmytable->szTitleAlign)); Edit_GetText(hCapEdit, lpmytable->szTitle, sizeof(lpmytable->szTitle)); lpmytable->bTitle = TRUE; } else { strcpy(lpmytable->szTitle, ""); strcpy(lpmytable->szTitleAlign, ""); lpmytable->bTitle = FALSE; } EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; case IDC_CHECK1: if (Button_GetCheck(hBorderCheck) == BST_CHECKED) { ShowWindow(hBorderEdit, SW_SHOW); bBorder = TRUE; } else { ShowWindow(hBorderEdit, SW_HIDE); bBorder = FALSE; } return TRUE; case IDC_CHECK2: if (Button_GetCheck(hCapCheck) == BST_CHECKED) { ShowWindow(hCapCombo, SW_SHOW); ShowWindow(hCapEdit, SW_SHOW); bCaption = TRUE; } else { ShowWindow(hCapCombo, SW_HIDE); ShowWindow(hCapEdit, SW_HIDE); bCaption = FALSE; } return TRUE; } return FALSE; } return FALSE; }
これも、DialogBoxParamの第1引数が変更となりました。BOOL MyInsertForm(HWND hEdit, HWND hEdit_hide) { MYFORMTAG fm; char szBuf[256]; if (DialogBoxParam(hInst, "MYFORMTAG", hEdit, (DLGPROC)MyFormProc, (LPARAM)&fm) == IDCANCEL) return FALSE; strcpy(szBuf, "<FORM"); if (fm.bMethod) { strcat(szBuf, " METHOD=\""); strcat(szBuf, fm.szMethod); strcat(szBuf, "\""); } if (fm.bAction) { strcat(szBuf, " ACTION=\""); strcat(szBuf, fm.szAction); strcat(szBuf, "\""); } if (fm.bName) { strcat(szBuf, " NAME=\""); strcat(szBuf, fm.szName); strcat(szBuf, "\""); } if (fm.bID) { strcat(szBuf, " ID=\""); strcat(szBuf, fm.szID); strcat(szBuf, "\""); } strcat(szBuf, ">\r\n</FORM>"); MyInsertTag(hEdit, hEdit_hide, szBuf); return TRUE; }
この部分に変更はありません。LRESULT CALLBACK MyFormProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp) { static LPMYFORMTAG lpfm; static HWND hMethodCheck, hActionCheck, hMethodCombo, hActionEdit, hNameCheck, hNameEdit, hIDCheck, hIDEdit; static BOOL bMethod, bAction, bName, bID; static char szMethod[8], szAction[64], szName[16], szID[16]; switch (msg) { case WM_INITDIALOG: lpfm = (LPMYFORMTAG)lp; hMethodCheck = GetDlgItem(hDlg, IDC_CHECK1); hActionCheck = GetDlgItem(hDlg, IDC_CHECK2); hMethodCombo = GetDlgItem(hDlg, IDC_COMBO1); hActionEdit = GetDlgItem(hDlg, IDC_EDIT1); hNameCheck = GetDlgItem(hDlg, IDC_CHECK3); hNameEdit = GetDlgItem(hDlg, IDC_EDIT2); hIDCheck = GetDlgItem(hDlg, IDC_CHECK4); hIDEdit = GetDlgItem(hDlg, IDC_EDIT3); ComboBox_AddString(hMethodCombo, "POST"); ComboBox_AddString(hMethodCombo, "GET"); if (bMethod) { Button_SetCheck(hMethodCheck, BST_CHECKED); EnableWindow(hMethodCombo, TRUE); } else { Button_SetCheck(hMethodCheck, BST_UNCHECKED); EnableWindow(hMethodCombo, FALSE); } if (bAction) { Button_SetCheck(hActionCheck, BST_CHECKED); EnableWindow(hActionEdit, TRUE); } else { Button_SetCheck(hActionCheck, BST_UNCHECKED); EnableWindow(hActionEdit, FALSE); } if (bName) { Button_SetCheck(hNameCheck, BST_CHECKED); EnableWindow(hNameEdit, TRUE); } else { Button_SetCheck(hNameCheck, BST_UNCHECKED); EnableWindow(hNameEdit, FALSE); } if (bID) { Button_SetCheck(hIDCheck, BST_CHECKED); EnableWindow(hIDEdit, TRUE); } else { Button_SetCheck(hIDCheck, BST_UNCHECKED); EnableWindow(hIDEdit, FALSE); } ComboBox_SetText(hMethodCombo, szMethod); Edit_SetText(hActionEdit, szAction); Edit_SetText(hNameEdit, szName); Edit_SetText(hIDEdit, szID); return TRUE; case WM_COMMAND: switch (LOWORD(wp)) { case IDOK: if (Button_GetCheck(hMethodCheck) == BST_CHECKED) { ComboBox_GetText(hMethodCombo, lpfm->szMethod, sizeof(lpfm->szMethod)); lpfm->bMethod = TRUE; bMethod = TRUE; } else { strcpy(lpfm->szMethod, ""); lpfm->bMethod = FALSE; bMethod = FALSE; } if (Button_GetCheck(hActionCheck) == BST_CHECKED) { Edit_GetText(hActionEdit, lpfm->szAction, sizeof(lpfm->szAction)); lpfm->bAction = TRUE; bAction = TRUE; } else { strcpy(lpfm->szAction, ""); lpfm->bAction = FALSE; bAction = FALSE; } if (Button_GetCheck(hNameCheck) == BST_CHECKED) { Edit_GetText(hNameEdit, lpfm->szName, sizeof(lpfm->szName)); lpfm->bName = TRUE; bName = TRUE; } else { strcpy(lpfm->szName, ""); lpfm->bName = FALSE; bName = FALSE; } if (Button_GetCheck(hIDCheck) == BST_CHECKED) { Edit_GetText(hIDEdit, lpfm->szID, sizeof(lpfm->szID)); lpfm->bID = TRUE; bID = TRUE; } else { strcpy(lpfm->szID, ""); lpfm->bID = FALSE; bID = FALSE; } strcpy(szMethod, lpfm->szMethod); strcpy(szAction, lpfm->szAction); strcpy(szName, lpfm->szName); strcpy(szID, lpfm->szID); EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; case IDC_CHECK1: if (Button_GetCheck(hMethodCheck) == BST_CHECKED) { EnableWindow(hMethodCombo, TRUE); bMethod = TRUE; } else { EnableWindow(hMethodCombo, FALSE); bMethod = FALSE; } return TRUE; case IDC_CHECK2: if (Button_GetCheck(hActionCheck) == BST_CHECKED) { EnableWindow(hActionEdit, TRUE); SetFocus(hActionEdit); bAction = TRUE; } else { EnableWindow(hActionEdit, FALSE); bAction = FALSE; } return TRUE; case IDC_CHECK3: if (Button_GetCheck(hNameCheck) == BST_CHECKED) { EnableWindow(hNameEdit, TRUE); SetFocus(hNameEdit); bName = TRUE; } else { EnableWindow(hNameEdit, FALSE); bName = FALSE; } return TRUE; case IDC_CHECK4: if (Button_GetCheck(hIDCheck) == BST_CHECKED) { EnableWindow(hIDEdit, TRUE); SetFocus(hIDEdit); bID = TRUE; } else { EnableWindow(hIDEdit, FALSE); bID = FALSE; } return TRUE; } return FALSE; } return FALSE; }
この部部にも変更はありません。LRESULT CALLBACK MyInputProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp) { static LPMYINPUTTAG lpin; static HWND hValueCheck, hValueEdit, hTypeCombo, hNameCheck, hIDCheck, hOnClickCheck, hNameEdit, hIDEdit, hOnClickEdit, hOnBlurCheck, hOnBlurEdit, hOnChangeCheck, hOnChangeEdit, hOnFocusCheck, hOnFocusEdit, hOnSubmitCheck, hOnSubmitEdit; static BOOL bValue, bName, bID, bOnClick, bOnBlur, bOnChange, bOnFocus, bOnSubmit; static char szType[16], szValue[64], szName[16], szID[16], szOnClick[64], szOnBlur[64], szOnChange[64], szOnFocus[64], szOnSubmit[64]; switch (msg) { case WM_INITDIALOG: lpin = (LPMYINPUTTAG)lp; hValueCheck = GetDlgItem(hDlg, IDC_CHECK1); hValueEdit = GetDlgItem(hDlg, IDC_EDIT1); hTypeCombo = GetDlgItem(hDlg, IDC_COMBO1); hNameCheck = GetDlgItem(hDlg, IDC_CHECK2); hIDCheck = GetDlgItem(hDlg, IDC_CHECK3); hOnClickCheck = GetDlgItem(hDlg, IDC_CHECK4); hNameEdit = GetDlgItem(hDlg, IDC_EDIT2); hIDEdit = GetDlgItem(hDlg, IDC_EDIT3); hOnClickEdit = GetDlgItem(hDlg, IDC_EDIT4); hOnBlurCheck = GetDlgItem(hDlg, IDC_CHECK5); hOnBlurEdit = GetDlgItem(hDlg, IDC_EDIT5); hOnChangeCheck = GetDlgItem(hDlg, IDC_CHECK6); hOnChangeEdit = GetDlgItem(hDlg, IDC_EDIT6); hOnFocusCheck = GetDlgItem(hDlg, IDC_CHECK7); hOnFocusEdit = GetDlgItem(hDlg, IDC_EDIT7); hOnSubmitCheck = GetDlgItem(hDlg, IDC_CHECK8); hOnSubmitEdit = GetDlgItem(hDlg, IDC_EDIT8); ComboBox_AddString(hTypeCombo, "button"); ComboBox_AddString(hTypeCombo, "text"); ComboBox_AddString(hTypeCombo, "radio"); ComboBox_AddString(hTypeCombo, "checkbox"); ComboBox_AddString(hTypeCombo, "submit"); ComboBox_AddString(hTypeCombo, "reset"); if (bValue) { ShowWindow(hValueEdit, SW_SHOW); Button_SetCheck(hValueCheck, BST_CHECKED); } else { ShowWindow(hValueEdit, SW_HIDE); Button_SetCheck(hValueCheck, BST_UNCHECKED); } if (bName) { ShowWindow(hNameEdit, SW_SHOW); Button_SetCheck(hNameCheck, BST_CHECKED); } else { ShowWindow(hNameEdit, SW_HIDE); Button_SetCheck(hNameCheck, BST_UNCHECKED); } if (bID) { ShowWindow(hIDEdit, SW_SHOW); Button_SetCheck(hIDCheck, BST_CHECKED); } else { ShowWindow(hIDEdit, SW_HIDE); Button_SetCheck(hIDCheck, BST_UNCHECKED); } if (bOnClick) { ShowWindow(hOnClickEdit, SW_SHOW); Button_SetCheck(hOnClickCheck, BST_CHECKED); } else { ShowWindow(hOnClickEdit, SW_HIDE); Button_SetCheck(hOnClickCheck, BST_UNCHECKED); } if (bOnBlur) { ShowWindow(hOnBlurEdit, SW_SHOW); Button_SetCheck(hOnBlurCheck, BST_CHECKED); } else { ShowWindow(hOnBlurEdit, SW_HIDE); Button_SetCheck(hOnBlurCheck, BST_UNCHECKED); } if (bOnChange) { ShowWindow(hOnChangeEdit, SW_SHOW); Button_SetCheck(hOnChangeCheck, BST_CHECKED); } else { ShowWindow(hOnChangeEdit, SW_HIDE); Button_SetCheck(hOnChangeCheck, BST_UNCHECKED); } if (bOnFocus) { ShowWindow(hOnFocusEdit, SW_SHOW); Button_SetCheck(hOnFocusCheck, BST_CHECKED); } else { ShowWindow(hOnFocusEdit, SW_HIDE); Button_SetCheck(hOnFocusCheck, BST_UNCHECKED); } if (bOnSubmit) { ShowWindow(hOnSubmitEdit, SW_SHOW); Button_SetCheck(hOnSubmitCheck, BST_CHECKED); } else { ShowWindow(hOnSubmitEdit, SW_HIDE); Button_SetCheck(hOnSubmitCheck, BST_UNCHECKED); } ComboBox_SetText(hTypeCombo, szType); Edit_SetText(hValueEdit, szValue); Edit_SetText(hNameEdit, szName); Edit_SetText(hIDEdit, szID); Edit_SetText(hOnClickEdit, szOnClick); Edit_SetText(hOnBlurEdit, szOnBlur); Edit_SetText(hOnChangeEdit, szOnChange); Edit_SetText(hOnFocusEdit, szOnFocus); Edit_SetText(hOnSubmitEdit, szOnSubmit); return TRUE; case WM_COMMAND: switch (LOWORD(wp)) { case IDOK: ComboBox_GetText(hTypeCombo, lpin->szType, sizeof(lpin->szType)); if (Button_GetCheck(hValueCheck) == BST_CHECKED) { Edit_GetText(hValueEdit, lpin->szValue, sizeof(lpin->szValue)); strcpy(szValue, lpin->szValue); lpin->bValue = TRUE; bValue = TRUE; } else { strcpy(lpin->szValue, ""); lpin->bValue = FALSE; bValue = FALSE; } if (Button_GetCheck(hNameCheck) == BST_CHECKED) { Edit_GetText(hNameEdit, lpin->szName, sizeof(lpin->szName)); lpin->bName = TRUE; bName = TRUE; } else { strcpy(lpin->szName, ""); lpin->bName = FALSE; bName = FALSE; } if (Button_GetCheck(hIDCheck) == BST_CHECKED) { Edit_GetText(hIDEdit, lpin->szID, sizeof(lpin->szID)); lpin->bID = TRUE; bID = TRUE; } else { strcpy(lpin->szID, ""); lpin->bID = FALSE; bID = FALSE; } if (Button_GetCheck(hOnClickCheck) == BST_CHECKED) { Edit_GetText(hOnClickEdit, lpin->szOnClick, sizeof(lpin->szOnClick)); lpin->bClick = TRUE; bOnClick = TRUE; } else { strcpy(lpin->szOnClick, ""); lpin->bClick = FALSE; bOnClick = FALSE; } if (Button_GetCheck(hOnBlurCheck) == BST_CHECKED) { Edit_GetText(hOnBlurEdit, lpin->szOnBlur, sizeof(lpin->szOnBlur)); lpin->bBlur = TRUE; bOnBlur = TRUE; } else { strcpy(lpin->szOnBlur, ""); lpin->bBlur = FALSE; bOnBlur = FALSE; } if (Button_GetCheck(hOnChangeCheck) == BST_CHECKED) { Edit_GetText(hOnChangeEdit, lpin->szOnChange, sizeof(lpin->szOnChange)); lpin->bChange = TRUE; bOnChange = TRUE; } else { strcpy(lpin->szOnChange, ""); lpin->bChange = FALSE; bOnChange = FALSE; } if (Button_GetCheck(hOnFocusCheck) == BST_CHECKED) { Edit_GetText(hOnFocusEdit, lpin->szOnFocus, sizeof(lpin->szOnFocus)); lpin->bFocus = TRUE; bOnFocus = TRUE; } else { strcpy(lpin->szOnFocus, ""); lpin->bFocus = FALSE; bOnFocus = FALSE; } if (Button_GetCheck(hOnSubmitCheck) == BST_CHECKED) { Edit_GetText(hOnSubmitEdit, lpin->szOnSubmit, sizeof(lpin->szOnSubmit)); lpin->bSubmit = TRUE; bOnSubmit = TRUE; } else { strcpy(lpin->szOnSubmit, ""); lpin->bSubmit = FALSE; bOnSubmit = FALSE; } strcpy(szType, lpin->szType); strcpy(szName, lpin->szName); strcpy(szID, lpin->szID); strcpy(szOnClick, lpin->szOnClick); strcpy(szOnBlur, lpin->szOnBlur); strcpy(szOnChange, lpin->szOnChange); strcpy(szOnFocus, lpin->szOnFocus); strcpy(szOnSubmit, lpin->szOnSubmit); EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; case IDC_CHECK1: if (Button_GetCheck(hValueCheck) == BST_CHECKED) { ShowWindow(hValueEdit, SW_SHOW); SetFocus(hValueEdit); bValue = TRUE; } else { ShowWindow(hValueEdit, SW_HIDE); bValue = FALSE; } case IDC_CHECK2: if (Button_GetCheck(hNameCheck) == BST_CHECKED) { ShowWindow(hNameEdit, SW_SHOW); SetFocus(hNameEdit); bName = TRUE; } else { ShowWindow(hNameEdit, SW_HIDE); bName = FALSE; } return TRUE; case IDC_CHECK3: if (Button_GetCheck(hIDCheck) == BST_CHECKED) { ShowWindow(hIDEdit, SW_SHOW); SetFocus(hIDEdit); bID = TRUE; } else { ShowWindow(hIDEdit, SW_HIDE); bID = FALSE; } return TRUE; case IDC_CHECK4: if (Button_GetCheck(hOnClickCheck) == BST_CHECKED) { ShowWindow(hOnClickEdit, SW_SHOW); SetFocus(hOnClickEdit); bOnClick = TRUE; } else { ShowWindow(hOnClickEdit, SW_HIDE); bOnClick = FALSE; } return TRUE; case IDC_CHECK5: if (Button_GetCheck(hOnBlurCheck) == BST_CHECKED) { ShowWindow(hOnBlurEdit, SW_SHOW); SetFocus(hOnBlurEdit); bOnBlur = TRUE; } else { ShowWindow(hOnBlurEdit, SW_HIDE); bOnBlur = FALSE; } return TRUE; case IDC_CHECK6: if (Button_GetCheck(hOnChangeCheck) == BST_CHECKED) { ShowWindow(hOnChangeEdit, SW_SHOW); SetFocus(hOnChangeEdit); bOnChange = TRUE; } else { ShowWindow(hOnChangeEdit, SW_HIDE); bOnChange = FALSE; } return TRUE; case IDC_CHECK7: if (Button_GetCheck(hOnFocusCheck) == BST_CHECKED) { ShowWindow(hOnFocusEdit, SW_SHOW); SetFocus(hOnFocusEdit); bOnFocus = TRUE; } else { ShowWindow(hOnFocusEdit, SW_HIDE); bOnFocus = FALSE; } return TRUE; case IDC_CHECK8: if (Button_GetCheck(hOnSubmitCheck) == BST_CHECKED) { ShowWindow(hOnSubmitEdit, SW_SHOW); SetFocus(hOnSubmitEdit); bOnSubmit = TRUE; } else { ShowWindow(hOnSubmitEdit, SW_HIDE); bOnSubmit = FALSE; } return TRUE; } return FALSE; } return FALSE; }
これも、DialogBoxParamの第1引数が変更になっています。BOOL MyInsertInput(HWND hEdit, HWND hEdit_hide) { MYINPUTTAG in; char szBuf[256]; if (DialogBoxParam(hInst, "MYINPUTTAG", hEdit, (DLGPROC)MyInputProc, (LPARAM)&in) == IDCANCEL) return FALSE; strcpy(szBuf, "<INPUT TYPE=\""); strcat(szBuf, in.szType); strcat(szBuf, "\""); if (in.bValue) { strcat(szBuf, " VALUE=\""); strcat(szBuf, in.szValue); strcat(szBuf, "\""); } if (in.bName) { strcat(szBuf, " NAME=\""); strcat(szBuf, in.szName); strcat(szBuf, "\""); } if (in.bID) { strcat(szBuf, " ID=\""); strcat(szBuf, in.szID); strcat(szBuf, "\""); } if (in.bClick) { strcat(szBuf, " onClick=\""); strcat(szBuf, in.szOnClick); strcat(szBuf, "\""); } if (in.bBlur) { strcat(szBuf, " onBlur=\""); strcat(szBuf, in.szOnBlur); strcat(szBuf, "\""); } if (in.bChange) { strcat(szBuf, " onChange=\""); strcat(szBuf, in.szOnChange); strcat(szBuf, "\""); } if (in.bFocus) { strcat(szBuf, " onFocus=\""); strcat(szBuf, in.szOnFocus); strcat(szBuf, "\""); } if (in.bSubmit) { strcat(szBuf, " onSubmit=\""); strcat(szBuf, in.szOnSubmit); strcat(szBuf, "\""); } strcat(szBuf, ">"); MyInsertTag(hEdit, hEdit_hide, szBuf); return TRUE; }
これらの関数に変更はありません。BOOL MyInsertScript(HWND hEdit, HWND hEdit_hide) { char szBuf[256]; strcpy(szBuf, "<SCRIPT LANGUAGE=\"JavaScript\">\r\n"); strcat(szBuf, "<!--\r\n\r\n//-->\r\n</SCRIPT>"); MyInsertTag(hEdit, hEdit_hide, szBuf); return TRUE; } HWND MakeMyToolbar(HWND hWnd, int n, TBBUTTON *tbButton, int id) { HWND hTool; TBADDBITMAP tbab; int stdid, i; hTool = CreateToolbarEx(hWnd, WS_VISIBLE | WS_CHILD| CCS_NODIVIDER | CCS_NORESIZE | TBSTYLE_FLAT, id , 0, NULL, NULL, tbButton, 0, 0, 0, 0, 0, sizeof(TBBUTTON)); tbab.hInst = HINST_COMMCTRL; tbab.nID = IDB_STD_SMALL_COLOR; stdid = SendMessage(hTool, TB_ADDBITMAP, n, (LPARAM)&tbab); for (i = 0; i < n; i++) tbButton[i].iBitmap += stdid; SendMessage(hTool, TB_ADDBUTTONS, n, (LONG)tbButton); SendMessage(hTool, TB_AUTOSIZE, 0, 0); return hTool; } BOOL MyOpen(HWND hEdit, HWND hEdit_hide) { int id; OPENFILENAME ofn; HGLOBAL hMem; HANDLE hFile; DWORD dwFSizeHigh, dwFSize, dwAccBytes; char *lpszBuf, szWinTitle[64]; HWND hParent; if (SendMessage(hEdit, EM_GETMODIFY, 0, 0) && strcmp(szFileTitle, "無題") != 0) { id = MessageBox(hEdit, "変更を保存しますか", "注意", MB_YESNO | MB_ICONQUESTION); if (id == IDYES) MySave(hEdit); } memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hEdit; ofn.lpstrFilter = "ソースファイル(htm, html)\0*.htm;*.html\0すべてのファイル(*.*)\0*.*\0\0"; ofn.lpstrFile = szFileName; ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFile = MAX_PATH; ofn.nMaxFileTitle = MAX_PATH; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = "html"; ofn.lpstrTitle = "HTMLソースファイルのオープン"; if (!GetOpenFileName(&ofn)) return FALSE; hFile = CreateFile(szFileName, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { MessageBox(hEdit, "ファイルをオープンできません", "Error", MB_OK); return FALSE; } dwFSize = GetFileSize(hFile, &dwFSizeHigh); if (dwFSizeHigh != 0) { MessageBox(hEdit, "ファイルが大きすぎます", "Error", MB_OK); CloseHandle(hFile); return FALSE; } hMem = GlobalAlloc(GHND, dwFSize + 1); if (hMem == NULL) { MessageBox(hEdit, "メモリを確保できません", "Error", MB_OK); CloseHandle(hFile); return FALSE; } lpszBuf = (char *)GlobalLock(hMem); ReadFile(hFile, lpszBuf, dwFSize, &dwAccBytes, NULL); lpszBuf[dwFSize] = '\0'; SetWindowText(hEdit, ""); MyInsertTag(hEdit, hEdit_hide, lpszBuf); wsprintf(szWinTitle, lpszWinTitleOrg, szFileTitle); hParent = GetParent(hEdit); SetWindowText(hParent, szWinTitle); CloseHandle(hFile); GlobalUnlock(hMem); GlobalFree(hMem); SendMessage(hEdit, EM_SETMODIFY, (WPARAM)FALSE, 0); return TRUE; } BOOL CheckMyMenu(HMENU hMenu, HWND hEdit, HWND hTool2) { HWND hWnd; DWORD dwStart, dwEnd; UINT uOK, uNO; uOK = MF_BYCOMMAND | MF_ENABLED; uNO = MF_BYCOMMAND | MF_GRAYED; hWnd = GetParent(hEdit); if (CanPaste(hWnd)) { EnableMenuItem(hMenu, IDM_PASTE, uOK); SendMessage(hTool2, TB_ENABLEBUTTON, (WPARAM)IDM_PASTE, (LPARAM)MAKELONG(TRUE, 0)); } else { EnableMenuItem(hMenu, IDM_PASTE, uNO); SendMessage(hTool2, TB_ENABLEBUTTON, (WPARAM)IDM_PASTE, (LPARAM)MAKELONG(FALSE, 0)); } if (SendMessage(hEdit, EM_GETMODIFY, 0, 0)) { EnableMenuItem(hMenu, IDM_UNDO, uOK); SendMessage(hTool2, TB_ENABLEBUTTON, (WPARAM)IDM_UNDO, (LPARAM)MAKELONG(TRUE, 0)); } else { EnableMenuItem(hMenu, IDM_UNDO, uNO); SendMessage(hTool2, TB_ENABLEBUTTON, (WPARAM)IDM_UNDO, (LPARAM)MAKELONG(FALSE, 0)); } SendMessage(hEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd); if (dwStart == dwEnd) { EnableMenuItem(hMenu, IDM_COPY, uNO); EnableMenuItem(hMenu, IDM_DELETE, uNO); EnableMenuItem(hMenu, IDM_CUT, uNO); SendMessage(hTool2, TB_ENABLEBUTTON, (WPARAM)IDM_COPY, (LPARAM)MAKELONG(FALSE, 0)); SendMessage(hTool2, TB_ENABLEBUTTON, (WPARAM)IDM_DELETE, (LPARAM)MAKELONG(FALSE, 0)); SendMessage(hTool2, TB_ENABLEBUTTON, (WPARAM)IDM_CUT, (LPARAM)MAKELONG(FALSE, 0)); } else { EnableMenuItem(hMenu, IDM_COPY, uOK); EnableMenuItem(hMenu, IDM_DELETE, uOK); EnableMenuItem(hMenu, IDM_CUT, uOK); SendMessage(hTool2, TB_ENABLEBUTTON, (WPARAM)IDM_COPY, (LPARAM)MAKELONG(TRUE, 0)); SendMessage(hTool2, TB_ENABLEBUTTON, (WPARAM)IDM_DELETE, (LPARAM)MAKELONG(TRUE, 0)); SendMessage(hTool2, TB_ENABLEBUTTON, (WPARAM)IDM_CUT, (LPARAM)MAKELONG(TRUE, 0)); } if (Edit_GetTextLength(hEdit) == 0) EnableMenuItem(hMenu, IDM_ALL, uNO); else EnableMenuItem(hMenu, IDM_ALL, uOK); return TRUE; } BOOL CanPaste(HWND hWnd) { HANDLE hMem; if (OpenClipboard(hWnd) == 0) { return FALSE; } hMem = GetClipboardData(CF_TEXT); if (hMem == NULL) { CloseClipboard(); return FALSE; } else { CloseClipboard(); return TRUE; } } LRESULT CALLBACK NewEditProc(HWND hEdit, UINT msg, WPARAM wp, LPARAM lp) { HWND hParent; static HWND hTool; HMENU hMenu; hParent = GetParent(hEdit); hMenu = GetMenu(hParent); switch (msg) { case MY_MSG: hTool = (HWND)lp; return 0; case WM_KEYUP: case WM_LBUTTONUP: CheckMyMenu(hMenu, hEdit, hTool); break; default: break; } return (CallWindowProc(OrgEditProc, hEdit, msg, wp, lp)); } BOOL MySetStatusText(HWND hStatus, int n, char *lpszBuf) { SendMessage(hStatus, SB_SETTEXT, (WPARAM)n, (LPARAM)lpszBuf); return TRUE; }
CreateToolbarEx関数の引数で、インスタンスハンドルのところが変更となっています。HWND MakeMyToolbar2(HWND hWnd, int n, TBBUTTON *tb, int nID, int nRID, int nRIDX) { HWND hTool; hTool = CreateToolbarEx(hWnd, //親ウィンドウ WS_CHILD | WS_VISIBLE | CCS_NODIVIDER | CCS_NORESIZE | TBSTYLE_FLAT, //ウィンドウスタイル nID, //コントロールID n, //ボタンイメージの数 hInst, //インスタンスハンドル nRID, //リソースID tb, //TBBUTTON構造体のアドレス n, //ボタンの数 0, 0, //ボタンの幅、高さ 0, 0, //ボタンイメージの幅、高さ sizeof(TBBUTTON)); //TBBUTTON構造体の大きさ if (hTool == NULL) { MessageBox(hWnd, "エラー", "Error", MB_OK); return NULL; } hImage = ImageList_LoadBitmap(hInst, MAKEINTRESOURCE(nRIDX), 16, 0, RGB(0, 0, 255)); SendMessage(hTool, TB_SETHOTIMAGELIST, 0, (LPARAM)hImage); SendMessage(hTool, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_DRAWDDARROWS); return hTool; }
ImageList_LoadBitmapの第1引数も変更となります。
これらの関数に変更はありません。HWND MakeMyToolTip(HWND hMain, HWND hTool, int nStart, int nEnd, TBBUTTON *tbButton, char (*szText)[256]) { HWND hTT; TOOLINFO ti; int i; RECT rc; HINSTANCE hInst; hInst = (HINSTANCE)GetWindowLong(hTool, GWL_HINSTANCE); hTT = CreateWindowEx(0, TOOLTIPS_CLASS, "", WS_POPUP | TTS_NOPREFIX | TTS_BALLOON | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hMain, (HMENU)NULL, hInst, NULL); SendMessage(hTT, TTM_SETTITLE, (WPARAM)1, (LPARAM)"Hint!"); memset(&ti, 0, sizeof(TOOLINFO)); ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS; ti.hwnd = hTool; ti.hinst = hInst; for (i = 0; i <= nEnd - nStart; i++) { SendMessage(hTool, TB_GETITEMRECT, i, (LPARAM)&ti.rect); ti.uId = tbButton[i].idCommand; ti.lpszText = szText[i + nStart]; SendMessage(hTT, TTM_ADDTOOL, 0, (LPARAM)&ti); } SendMessage(hTool, TB_SETTOOLTIPS, (WPARAM)hTT, 0); rc.top = 5; rc.left = 5; rc.bottom = 5; rc.right = 5; SendMessage(hTT, TTM_SETMARGIN, 0, (LPARAM)&rc); SendMessage(hTT, TTM_SETMAXTIPWIDTH, 0, (LPARAM)200); return hTT; } void SetTipColor(HWND hWnd, HWND *lphTip, COLORREF *lpcrTip, int nNo) { CHOOSECOLOR cc; static DWORD dwCust[16]; int i; memset(&cc, 0, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hWnd; cc.lpCustColors = dwCust; cc.rgbResult = *lpcrTip; cc.Flags = CC_RGBINIT; if(ChooseColor(&cc)) { *lpcrTip = cc.rgbResult; for (i = 0; i < nNo; i++) SendMessage(lphTip[i], TTM_SETTIPTEXTCOLOR, (WPARAM)*lpcrTip, 0); } return; } void SetTipBkColor(HWND hWnd, HWND *lphTip, COLORREF *lpcrTipBk, int nNo) { CHOOSECOLOR cc; static DWORD dwCust[16]; int i; memset(&cc, 0, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hWnd; cc.lpCustColors = dwCust; cc.rgbResult = *lpcrTipBk; cc.Flags = CC_RGBINIT; if(ChooseColor(&cc)) { *lpcrTipBk = cc.rgbResult; for (i = 0; i < nNo; i++) SendMessage(lphTip[i], TTM_SETTIPBKCOLOR, (WPARAM)*lpcrTipBk, 0); } return; } BOOL GetInitialSetting(LPMYINITIALDATA lpmyinit) { HKEY hKey; DWORD dwResult, dwType, dwByte; LONG lResult; lResult = RegCreateKeyEx(HKEY_CURRENT_USER, "SoftWare\\Kumei\\htmledit", 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwResult); if (lResult != ERROR_SUCCESS) { MessageBox(NULL, "レジストリ操作に失敗しました", "Error", MB_OK); return FALSE; } else if (dwResult == REG_CREATED_NEW_KEY) { return FALSE; } dwType = REG_DWORD; dwByte = (DWORD)sizeof(DWORD); RegQueryValueEx(hKey, "x", NULL, &dwType, (BYTE *)&(lpmyinit->x), &dwByte); RegQueryValueEx(hKey, "y", NULL, &dwType, (BYTE *)&(lpmyinit->y), &dwByte); RegQueryValueEx(hKey, "wx", NULL, &dwType, (BYTE *)&(lpmyinit->wx), &dwByte); RegQueryValueEx(hKey, "wy", NULL, &dwType, (BYTE *)&(lpmyinit->wy), &dwByte); dwByte = sizeof(COLORREF); RegQueryValueEx(hKey, "TipTextColor", NULL, &dwType, (BYTE *)&(lpmyinit->crTipText), &dwByte); RegQueryValueEx(hKey, "TipBkColor", NULL, &dwType, (BYTE *)&(lpmyinit->crTipBackground), &dwByte); RegCloseKey(hKey); return TRUE; } BOOL SetInitialSetting(LPMYINITIALDATA lpmyinit) { HKEY hKey; DWORD dwResult; LONG lResult; lResult = RegCreateKeyEx(HKEY_CURRENT_USER, "SoftWare\\Kumei\\htmledit", 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwResult); if (lResult != ERROR_SUCCESS) { MessageBox(NULL, "レジストリ操作に失敗しました", "Error", MB_OK); return FALSE; } RegSetValueEx(hKey, "x", 0, REG_DWORD, (CONST BYTE *)&(lpmyinit->x), sizeof(DWORD)); RegSetValueEx(hKey, "y", 0, REG_DWORD, (CONST BYTE *)&(lpmyinit->y), sizeof(DWORD)); RegSetValueEx(hKey, "wx", 0, REG_DWORD, (CONST BYTE *)&(lpmyinit->wx), sizeof(DWORD)); RegSetValueEx(hKey, "wy", 0, REG_DWORD, (CONST BYTE *)&(lpmyinit->wy), sizeof(DWORD)); RegSetValueEx(hKey, "TipTextColor", 0, REG_DWORD, (CONST BYTE *)&(lpmyinit->crTipText), sizeof(COLORREF)); RegSetValueEx(hKey, "TipBkColor", 0, REG_DWORD, (CONST BYTE *)&(lpmyinit->crTipBackground), sizeof(COLORREF)); RegCloseKey(hKey); return TRUE; }
CreateToolbarExや CreateToolbarEx関数のLoadString関数の引数が変更となっています。HWND MakeMyToolbarMenu(HWND hRebar) { HWND hTool; int iFile, iEdit, iInsert, iBrowser, iOption; char szBuf[32]; hTool = CreateToolbarEx(hRebar, //親ウィンドウ WS_CHILD | WS_VISIBLE | CCS_NODIVIDER | CCS_NORESIZE | TBSTYLE_LIST | TBSTYLE_FLAT, //ウィンドウスタイル ID_TOOLMENU, //ID 0, //ボタンイメージの数 hInst, //ビットマップリソースの入っているモジュール NULL,//IDR_TOOLBAR1, //ビットマップリソースのID tbButtonMenu, //TBBUTTON構造体のアドレス 0, //ツールバーに加えるボタンの数 0, 0, 0, 0, //ボタンの幅、高さ、イメージの幅、高さ sizeof(TBBUTTON)); //TBBUTTON構造体の大きさ LoadString(hInst, IDS_FILE, szBuf, sizeof(szBuf) - 1); iFile = SendMessage(hTool, TB_ADDSTRING, 0, (LPARAM)szBuf); tbButtonMenu[0].iString = iFile; LoadString(hInst, IDS_EDIT, szBuf, sizeof(szBuf) - 1); iEdit = SendMessage(hTool, TB_ADDSTRING, 0, (LPARAM)szBuf); tbButtonMenu[1].iString = iEdit; LoadString(hInst, IDS_INSERT, szBuf, sizeof(szBuf) - 1); iInsert = SendMessage(hTool, TB_ADDSTRING, 0, (LPARAM)szBuf); tbButtonMenu[2].iString = iInsert; LoadString(hInst, IDS_BROWSER, szBuf, sizeof(szBuf) - 1); iBrowser = SendMessage(hTool, TB_ADDSTRING, 0, (LPARAM)szBuf); tbButtonMenu[3].iString = iBrowser; LoadString(hInst, IDS_OPTION, szBuf, sizeof(szBuf) - 1); iOption = SendMessage(hTool, TB_ADDSTRING, 0, (LPARAM)szBuf); tbButtonMenu[4].iString = iOption; SendMessage(hTool, TB_ADDBUTTONS, 5, (LPARAM)tbButtonMenu); return hTool; }
LoadMenu関数の第1引数が変更となっています。BOOL ShowMyPopMenu(HWND hWnd, HWND hToolMenuW, char *szMenuName, int nId, HWND hEdit, HWND hTool2) { RECT rc, rc_scr; POINT pt; HMENU hMenu, hSubMenu; int nCommandID[] = {IDM_FILE, IDM_EDIT, IDM_INSERT, IDM_BRVIEW, IDM_OPTION}; SendMessage(hToolMenuW, TB_GETITEMRECT, (WPARAM)nId, (LPARAM)&rc); pt.x = rc.left; pt.y = rc.top; ClientToScreen(hToolMenuW, &pt); rc_scr.left = pt.x; rc_scr.top = pt.y; pt.x = rc.right; pt.y = rc.bottom; ClientToScreen(hToolMenuW, &pt); rc_scr.right = pt.x; rc_scr.bottom = pt.y; hMenu = LoadMenu(hInst, szMenuName); if (hMenu == NULL) { MessageBox(hWnd, "LoadMenu Error", "Error", MB_OK); return FALSE; } hSubMenu = GetSubMenu(hMenu, nId); CheckMyMenu(hMenu, hEdit, hTool2); SendMessage(hToolMenuW, TB_SETHOTITEM, (WPARAM)-1, 0); SendMessage(hToolMenuW, TB_SETSTATE, (WPARAM)nCommandID[nId], ((LPARAM)MAKELONG(TBSTATE_ENABLED | TBSTATE_PRESSED, 0))); TrackPopupMenu(hSubMenu, TPM_LEFTALIGN, rc_scr.left, rc_scr.bottom, 0, hWnd, NULL); DestroyMenu(hMenu); SendMessage(hToolMenuW, TB_SETSTATE, (WPARAM)nCommandID[nId], ((LPARAM)MAKELONG(TBSTATE_ENABLED, 0))); return TRUE; }
これらの関数に変更はありません。LRESULT CALLBACK KbdHook(int code, WPARAM wp, LPARAM lp) { int nId, nBtnNo; UINT uId; int nCommandID[] = {IDM_FILE, IDM_EDIT, IDM_INSERT, IDM_BRVIEW, IDM_OPTION}; BOOL bPressed; if (code < 0) return CallNextHookEx(hHook, code, wp, lp); switch (code) { case HC_ACTION: nBtnNo = SendMessage(hMytoolMenu, TB_BUTTONCOUNT, 0, 0); nId = SendMessage(hMytoolMenu, TB_GETHOTITEM, 0, 0); if (HIWORD(lp) & KF_UP) bPressed = FALSE; else bPressed = TRUE; if ((wp == VK_F10 || wp == VK_MENU) && nId == -1 && bPressed) { SendMessage(hMytoolMenu, TB_SETHOTITEM, 0, 0); return -100; } if (wp == VK_ESCAPE) { SendMessage(hMytoolMenu, TB_SETHOTITEM, (WPARAM)-1, 0); break; } if (wp == VK_LEFT && nId != -1 && nId != 0 && bPressed) { SendMessage(hMytoolMenu, TB_SETHOTITEM, (WPARAM)nId - 1, 0); break; } if (wp == VK_RIGHT && nId != -1 && nId < nBtnNo && bPressed) { SendMessage(hMytoolMenu, TB_SETHOTITEM, (WPARAM)nId + 1, 0); break; } if (SendMessage(hMytoolMenu, TB_MAPACCELERATOR, (WPARAM)wp, (LPARAM)&uId) != 0 && nId != -1 ) { ShowMyPopMenu(hParent, hMytoolMenu, "MYMENU", uId - IDM_FILE, hEdit_g, hTool2_g); return -200; } default: break; } return CallNextHookEx(hHook, code, wp, lp); } BOOL MyCreateFileFromResource(HWND hEdit, HWND hE_hide, char *szResourceName, char *szResourceType, char *szResFileName) { HMODULE hExe; HRSRC hRs; HGLOBAL hMem; HANDLE hFile; LPBYTE lpByte; DWORD dwWritten, dwResSize; if (strcmp(szFileName, "") == 0) { MessageBox(hEdit, "まず名前を付けて保存してください。", "注意", MB_OK | MB_ICONEXCLAMATION); return FALSE; } hExe = LoadLibrary(szExeName); if (hExe == NULL) { MessageBox(hEdit, "LoadLibrary Error", "Error", MB_OK); return FALSE; } hRs = FindResource(hExe, szResourceName, szResourceType); if (hRs == NULL) { MessageBox(hEdit, "FindResource Error", "Error", MB_OK); return FALSE; } dwResSize = SizeofResource(hExe, hRs); hMem = LoadResource(hExe, hRs); lpByte = (BYTE *)LockResource(hMem); hFile = CreateFile(szResFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { MessageBox(NULL, "CreateFile Error", "OK", MB_OK); return FALSE; } WriteFile(hFile, lpByte, dwResSize, &dwWritten, NULL); CloseHandle(hFile); if (dwResSize != dwWritten) { MessageBox(hEdit, "WriteFile Error", "Error", MB_OK); return FALSE; } MyInsertTag(hEdit, hE_hide, "<IMG SRC=\""); MyInsertTag(hEdit, hE_hide, szResFileName); MyInsertTag(hEdit, hE_hide, "\">"); if (!MySave(hEdit)) return FALSE; return TRUE; }
やはり、DialogBoxParamの引数が変更となっています。BOOL MyDirectAniText(HWND hEdit, HWND hEdit_hide) { MYDIRECTTEXT mydirect; char szBuf[64]; 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; }
これらの関数に変更はありません。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; } 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; }
これが今回新たに作ったダイアログです。
「リピート」にチェックが付くとその横のエディットコントロールが 使用可能となります。リピートする回数を入力します。0だとリピートしません (チェックを付けないのと同じ)。
-1を指定すると永久にリピートします。
今回、新しく作った関数です。BOOL MyDirectAniPath(HWND hEdit, HWND hEdit_hide) { MYDIRECTANIPATH mypath; char szBuf[1024]; if (DialogBoxParam(hInst, "MYDIRECTPATH", hEdit, (DLGPROC)MyDirectPathProc, (LPARAM)&mypath) == IDCANCEL) return FALSE; strcpy(szBuf, "<OBJECT ID=\""); strcat(szBuf, mypath.szObjectID); strcat(szBuf, "\" CLASSID=\"CLSID:D7A7D7C3-D47F-11D0-89D3-00A0C90833E6\">\r\n"); strcat(szBuf, "<PARAM NAME=\"AutoStart\" VALUE=\""); if (mypath.bAutoStart) strcat(szBuf, "-1"); else strcat(szBuf, "0"); strcat(szBuf, "\">\r\n"); strcat(szBuf, "<PARAM NAME=\"Repeat\" VALUE=\""); if (mypath.bRepeat) strcat(szBuf, mypath.szRepeatNo); else strcat(szBuf, "0"); strcat(szBuf, "\">\r\n"); strcat(szBuf, "<PARAM NAME=\"Bounce\" VALUE=\""); if (mypath.bBounce) strcat(szBuf, "-1"); else strcat(szBuf, "0"); strcat(szBuf, "\">\r\n"); strcat(szBuf, "<PARAM NAME=\"Duration\" VALUE=\""); strcat(szBuf, mypath.szDuration); strcat(szBuf, "\">\r\n"); strcat(szBuf, "<PARAM NAME=\"Shape\" VALUE=\""); strcat(szBuf, mypath.szShape); strcat(szBuf, "("); strcat(szBuf, mypath.szCoordinate); strcat(szBuf, ")\">\r\n"); strcat(szBuf, "<PARAM NAME=\"Target\" VALUE=\""); strcat(szBuf, mypath.szTarget); strcat(szBuf, "\">\r\n"); strcat(szBuf, "<PARAM NAME=\"TimerInterval\" VALUE=\""); strcat(szBuf, mypath.szTimerInterval); strcat(szBuf, "\">\r\n</OBJECT>"); MyInsertTag(hEdit, hEdit_hide, szBuf); return TRUE; }
DialogBoxParamでダイアログを呼び出して、OKボタンが押されたら必要なタグを 挿入します。 OKボタン以外の時は何もせずに、FALSEを返します。
ダイアログのプロシージャです。LRESULT CALLBACK MyDirectPathProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp) { static LPMYDIRECTANIPATH lpmypath; static HWND hAutostart, hBounce, hRepeat, hRepeatEdit, hObjectID, hDuration, hTarget, hShape, hCoordinate, hInterval; switch (msg) { case WM_INITDIALOG: lpmypath = (LPMYDIRECTANIPATH)lp; hAutostart = GetDlgItem(hDlg, IDC_AUTOSTART); hBounce = GetDlgItem(hDlg, IDC_BOUNCE); hRepeat = GetDlgItem(hDlg, IDC_REPEAT); hRepeatEdit = GetDlgItem(hDlg, IDC_REPEATEDIT); hObjectID = GetDlgItem(hDlg, IDC_OBJECTID); hDuration = GetDlgItem(hDlg, IDC_DURATION); hTarget = GetDlgItem(hDlg, IDC_TARGET); hShape = GetDlgItem(hDlg, IDC_SHAPE); hCoordinate = GetDlgItem(hDlg, IDC_COORDINATE); hInterval = GetDlgItem(hDlg, IDC_INTERVAL); EnableWindow(hRepeatEdit, FALSE); ComboBox_InsertString(hShape, 0, "PolyLine"); ComboBox_InsertString(hShape, 0, "Oval"); ComboBox_InsertString(hShape, 0, "Rect"); return TRUE; case WM_COMMAND: switch (LOWORD(wp)) { case IDOK: if (Button_GetCheck(hAutostart) == BST_CHECKED) lpmypath->bAutoStart = TRUE; else lpmypath->bAutoStart = FALSE; if (Button_GetCheck(hBounce) == BST_CHECKED) lpmypath->bBounce = TRUE; else lpmypath->bBounce = FALSE; if (Button_GetCheck(hRepeat) == BST_CHECKED) { lpmypath->bRepeat = TRUE; Edit_GetText(hRepeatEdit, lpmypath->szRepeatNo, sizeof(lpmypath->szRepeatNo)); } else { lpmypath->bRepeat = FALSE; strcpy(lpmypath->szRepeatNo, "0"); } Edit_GetText(hObjectID, lpmypath->szObjectID, sizeof(lpmypath->szObjectID)); Edit_GetText(hDuration, lpmypath->szDuration, sizeof(lpmypath->szDuration)); Edit_GetText(hTarget, lpmypath->szTarget, sizeof(lpmypath->szTarget)); ComboBox_GetText(hShape, lpmypath->szShape, sizeof(lpmypath->szShape)); Edit_GetText(hCoordinate, lpmypath->szCoordinate, sizeof(lpmypath->szCoordinate)); Edit_GetText(hInterval, lpmypath->szTimerInterval, sizeof(lpmypath->szTimerInterval)); EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; case IDC_REPEAT: if (IsWindowEnabled(hRepeatEdit)) EnableWindow(hRepeatEdit, FALSE); else { EnableWindow(hRepeatEdit, TRUE); SetFocus(hRepeatEdit); } return TRUE; } return FALSE; } return FALSE; }
IDC_REPEATのチェックボックスがクリックされるたびにその横の エディットコントロールが使用可能となったり使用不能となったりしています。
Update 03/Nov/2001 By Y.Kumei