文書番号: 410498
最終更新日: 1999/03/21
// Header File // WORD ParamTypeKeyPress [] ={ET_I2}; typedef struct tagParamTypeKeyPress { int far *KeyAscii; LPVOID Index; } KEYPRESSPARAMS; EVENTINFO Event_KeyPress = { "KeyPress", // Name 1, // Num of Arguments 2, // Num of Word of Arguments ParamTypeKeyPress, "KeyAscii As Integer" }; //------------------------------------------------------------------ // Event list //------------------------------------------------------------------ // Define the consecutive indicies for the events //------------------------------------------------------------------ #define IEVENT_KEYPRESS 0 PEVENTINFO Circle_Events[] = { &Event_KeyPress, NULL }; // Message Handling // //------------------------------------------------------------------ // Control Procedure //------------------------------------------------------------------ LONG FAR PASCAL _export EditCtlProc ( HCTL hctl, HWND hwnd, USHORT msg, USHORT wp, LONG lp ) { KEYPRESSPARAMS params; MSG WchMsg; USHORT newwp; BYTE isdbcs; BYTE SubClassOfEdit; isbcs = FALSE; SubClassOfEdit = TRUE; // もし、hwnd が Edit クラスでなければ、FALSE にする。 // Edit Class は Trailing Byte を Remove するため // Edit Class 以外では、FALSE にする。 // 制限: KeyPreview = TRUE の時、Form 側の KeyPress が化ける。 // 正しくは、KeyPreview の設定を調べて、 // KeyPreview = TRUE の時には、TRUE にする。 switch (msg) { // 他のメッセージ処理 case WM_CHAR: newwp = wp; if (IsDBCSLeadByte((BYTE)wp)) { isdbcs = TRUE; if(PeekMessage(&WchMsg, hwnd, WM_CHAR, WM_CHAR, PM_NOYIELD | PM_NOREMOVE)) { // Leading バイトだけでなく SHIFT-JIS を KeyAscii に渡す。 newwp = (wp << 8) + (WORD)WchMsg.wParam; } } params.KeyAscii = &newwp; VBFireEvent(hctl, IEVENT_KEYPRESS, ¶ms); if (!SubClassOfEdit) PeekMessage(&WchMsg, hwnd, WM_CHAR, WM_CHAR, PM_NOYIELD | PM_REMOVE); // 入力された文字 KeyPress で KeyAscii 結果 // に入力されたコード // SBCS1 SBCS2 SBCS2(変更) // SBCS1 DBCS1 SBCS1(無変更) // SBCS1 0 無効化する。 // DBCS1 SBCS1 DBCS1(無変更) // DBCS1 DBCS2 DBCS1(無変更) // DBCS1 0 無効化する。 if (*params.KeyAscii) { BYTE b = (BYTE)((*params.KeyAscii)>>8); if (!IsDBCSLeadByte(b)) { if (!isdbcs) // wp が leading byte でないときのみ変更する。 { wp = (BYTE)(*params.KeyAscii); } else { if (SubClassOfEdit) PeekMessage(&WchMsg, hwnd, WM_CHAR, WM_CHAR, PM_NOYIELD | PM_REMOVE); } } } if (*params.KeyAscii==0) return 0; // KeyAscii = 0 の時は、WM_CHAR を渡さない。 break; // 他のメッセージ処理 } return VBDefControlProc(hctl, hwnd, msg, wp, lp); }
Keywords: KBHOWTO KB410498
Technology: kbAudDeveloper kbVBSearch kbZNotKeyword2 kbZNotKeyword6