Example #1
0
File: khserver.c Project: komh/kime
MRESULT khs_umStoreKeyInfo( HWND hwnd, MPARAM mp1, MPARAM mp2 )
{
    PKHSCD  pkhscd = WinQueryWindowPtr( hwnd, 0 );
    USHORT  fsFlags = SHORT1FROMMP( mp1 );
    UCHAR   ucRepeat = CHAR3FROMMP( mp1 );
    UCHAR   ucScancode = CHAR4FROMMP( mp1 );
    USHORT  usCh = SHORT1FROMMP( mp2 );
    USHORT  usVk = SHORT2FROMMP( mp2 );

    fprintf( pkhscd->fp, "fl : %04X, rp : %02d, sc : %02X, ch : %02X, vk : %02X\n",
                         fsFlags, ucRepeat, ucScancode, usCh, usVk );
    fflush( pkhscd->fp );

    return 0;
}
Example #2
0
File: kimehook.c Project: komh/kime
BOOL kimeAccelHook( PQMSG pQmsg )
{
    if( pQmsg->msg == WM_CHAR
#ifndef ODIN_SUPPORT_IN_INPUT_HOOK
        || pQmsg->msg == WM_CHAR_SPECIAL
#endif
      )
    {
        USHORT  fsFlags = SHORT1FROMMP( pQmsg->mp1 );
        UCHAR   ucRepeat = CHAR3FROMMP( pQmsg->mp1 );
        UCHAR   ucScancode = CHAR4FROMMP( pQmsg->mp1 );
        USHORT  usCh = SHORT1FROMMP( pQmsg->mp2 );
        USHORT  usVk = SHORT2FROMMP( pQmsg->mp2 );

        ULONG flHIAState;
        BOOL  hanIn;
        BOOL  consumed;
        BOOL  callHanja;
        //BOOL  patched;

        if( queryRunningHCHLB())
        {
            WinSendMsg( hwndHIA, HIAM_CHAR, pQmsg->mp1, pQmsg->mp2 );
            return TRUE;
        }

        //patched = FALSE;

        if(( fsFlags & KC_VIRTUALKEY ) &&
           ( usVk == VK_PAGEDOWN + 0x90 ) &&
           ( ucScancode = 0x96 ))
        {
            usVk = VK_PAGEDOWN;
            ucScancode = 0x67;

            pQmsg->mp1 = MPFROMSH2CH( fsFlags, ucRepeat, ucScancode );
            pQmsg->mp2 = MPFROM2SHORT( usCh, usVk );

            //patched = TRUE;
        }

        if(( fsFlags & KC_SCANCODE ) && ( ucScancode == 0x2B ) && ( fsFlags & KC_INVALIDCHAR ))
        {
            fsFlags &= ~KC_INVALIDCHAR;
            fsFlags |= KC_CHAR;

            usCh = 0x5C;

            pQmsg->mp1 = MPFROMSH2CH( fsFlags, ucRepeat, ucScancode );
            pQmsg->mp2 = MPFROM2SHORT( usCh, usVk );

            //patched = TRUE;
        }

        callHanja = isHanjaKey( fsFlags, ucScancode, usVk, usCh );
        if((( fsFlags & KC_KEYUP ) ||
            (( fsFlags & 0x0FFF ) == KC_SCANCODE ) ||
            !( fsFlags & KC_SCANCODE )) && !callHanja )
            return FALSE;

#ifdef FOCUS_ON
        dprintf(("inputFocusChanged %d, hwndCurrentInput %04X\n",
                 inputFocusChanged, hwndCurrentInput ));

        if( inputFocusChanged || ( hwndCurrentInput != pQmsg->hwnd ))
        {
            inputFocusChanged = FALSE;

            hwndCurrentInput = pQmsg->hwnd;

            supportDBCS = checkDBCSSupport( hwndCurrentInput );
            exception = checkExceptWindow( hwndCurrentInput );
        }
#else
        dprintf(("hwndCurrentInput %04X\n", hwndCurrentInput ));

        if( hwndCurrentInput != pQmsg->hwnd )
        {
            hwndCurrentInput = pQmsg->hwnd;

            initKimeStatus( hwndCurrentInput, FALSE );

            supportDBCS = checkDBCSSupport( hwndCurrentInput );
            exception = checkExceptWindow( hwndCurrentInput );
        }
#endif

        dprintf(("hwndCurrentInput %04X, supportDBCS %d, exception %d\n",
                  hwndCurrentInput, supportDBCS, exception ));

        if(( fsFlags & ( KC_CTRL | KC_SHIFT )) &&
           (( fsFlags & KC_VIRTUALKEY ) && ( usVk == VK_SPACE )))
            supportDBCS = checkDBCSSupport( hwndCurrentInput );

        if( kimeOpt.useOS2IME )
        {
            if( exception /* || !supportDBCS */)
                return FALSE;

            if((( fsFlags & ( KC_ALT | KC_CTRL | KC_SHIFT )) == KC_SHIFT ) &&
               (( fsFlags & KC_VIRTUALKEY ) && ( usVk == VK_SPACE )))
            {
                toggleOS2IMEHanEng( hwndCurrentInput );

                return TRUE;
            }

#if 0
            if( callHanja )
            {
                callIMEHanja( pQmsg->hwnd );
                return TRUE;
            }
#endif
            return FALSE;
        }

        dprintf(("hwndCurrentInput %04X, supportDBCS %d, exception %d\n",
                  hwndCurrentInput, supportDBCS, exception ));

        if( !hwndCurrentInput || !supportDBCS || exception )
            return FALSE;

        if(( fsFlags & ( KC_CTRL | KC_SHIFT )) &&
           (( fsFlags & KC_VIRTUALKEY ) && ( usVk == VK_SPACE )))
            return ( BOOL )WinSendMsg( hwndHIA, WM_CHAR, pQmsg->mp1, pQmsg->mp2 );

        flHIAState = (ULONG) WinSendMsg( hwndHIA, HIAM_QUERYSTATE, 0L, 0L );
        hanIn = flHIAState & HIAST_HANMODE;

#if 0
        if( !HIUSHORT( flHIAState ) &&
            ( fsFlags & ( KC_VIRTUALKEY | KC_CTRL | KC_ALT )) &&
            !callHanja )
            return FALSE;
#endif

        if( hanIn /*|| patched */ )
        {
            //MPARAM mp2;

            consumed = FALSE;

            if( callHanja )
            {
                WinPostMsg( hwndKime, KIMEM_CALLHANJAINPUT, 0, 0 );
                consumed = TRUE;
            }
            else if((( fsFlags & KC_CHAR ) || (( fsFlags & KC_VIRTUALKEY ) && (( usVk == VK_ESC ) || ( usVk == VK_SHIFT )))) &&
                    !(( fsFlags & KC_VIRTUALKEY ) && (( usVk == VK_TAB )/* || ( usVk == VK_SPACE )*/)))
            {
                //mp2 = pQmsg->mp2;
                //kbdKeyTranslate( pQmsg );
                consumed = (BOOL)WinSendMsg( hwndHIA, WM_CHAR, pQmsg->mp1, pQmsg->mp2 );
                //pQmsg->mp2 = mp2;
            }
            else if( !isHanjaKey( fsFlags | KC_LONEKEY, ucScancode, usVk, usCh ))
                WinSendMsg( hwndHIA, HIAM_COMPLETEHCH, 0, 0 );

            if( !consumed )
            {
                if( !HIUSHORT( flHIAState ))
                    return FALSE;

                if( fsFlags & ( KC_CTRL | KC_ALT ))
                    return FALSE;

                if(( fsFlags & KC_VIRTUALKEY ) && (( usVk == VK_SHIFT ) || (( usVk >= VK_F1 ) && ( usVk <= VK_F24 ))))
                    return FALSE;

#ifndef ODIN_SUPPORT_IN_INPUT_HOOK
                if( pQmsg->msg == WM_CHAR )
                {
#endif

#if 0
                    // IME do as the following.
                    if( HIUSHORT( flHIAState ) && ( fsFlags & KC_CHAR ) && ( usCh == ' ' ))
                    {
                        pQmsg->mp1 = MPFROMSH2CH( KC_CHAR, ucRepeat, 0 );
                        pQmsg->mp2 = MPFROM2SHORT( usCh, 0 );
                    }
#endif

#ifndef ODIN_SUPPORT_IN_INPUT_HOOK
                }
#endif
                WinPostMsg( pQmsg->hwnd, pQmsg->msg, pQmsg->mp1, pQmsg->mp2 );
            }

            return TRUE;
        }
    }

    return FALSE;
}
Example #3
0
File: hin.c Project: komh/hanedit2
MRESULT hia_wmChar(HWND hwnd,MPARAM mp1,MPARAM mp2)
{
USHORT  fsFlags = SHORT1FROMMP(mp1);
UCHAR   ucVkey  = CHAR3FROMMP(mp2);
UCHAR   ucChar  = CHAR1FROMMP(mp2);
UCHAR   ucScancode = CHAR4FROMMP(mp1);

HIA     *hia    = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE);

USHORT ckey;

//  printf("HIA:: WM_CHAR\n");

    if (fsFlags & KC_KEYUP) return 0L;

    if( hia->isHanjaKey != NULL )
    {
        if( hia->isHanjaKey( fsFlags, ucScancode, ucVkey, ucChar ))
        {
            if( hia->inbuf->newpos != HIABUF_NONE )
            {
                HANCHAR hch = SHORT1FROMMR( WinSendMsg( hwnd, HIAM_QUERYWORKINGHCH, 0, 0 ));
                HANCHAR hj;

                hj = hjselDlg( HWND_DESKTOP, hia->responseTo->hwnd, NULLHANDLE, hch );
                if( hj != HCH_SINGLE_SPACE )
                    hch = hj;

                WinSendMsg( hwnd, HIAM_CANCELBUF, 0, 0 );
                HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROMSHORT(hch));
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROMSHORT(hch));

                //WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );
                //HIA_NotifyToConnected( hia, HIAN_HGHJCONVERT, MPFROMLONG( TRUE ));
            }
            else
                HIA_NotifyToConnected( hia, HIAN_HGHJCONVERT, 0);

            return MRFROMLONG( TRUE );
        }
    }

    if( hia->isSpecialCharKey != NULL )
    {
        if( hia->isSpecialCharKey( fsFlags, ucScancode, ucVkey, ucChar ))
        {
            SCSELINFO scselInfo = { -1, -1, -1 };

            WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );

            scselDlg( HWND_DESKTOP, hia->responseTo->hwnd, NULLHANDLE, &scselInfo );
            if( scselInfo.hch != HCH_SINGLE_SPACE )
            {
                HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROMSHORT(scselInfo.hch));
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROMSHORT(scselInfo.hch));
            }

            return MRFROMLONG( TRUE );
        }
    }

    if (fsFlags & KC_VIRTUALKEY)
        {
        switch (ucVkey) {
        case VK_SPACE:
            WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            if (FKC_SHIFTONLY(fsFlags))
                WinSendMsg(hwnd,HIAM_CHANGEHANMODE,0L,0L);
            else if (FKC_CTRLONLY(fsFlags))
                WinSendMsg(hwnd,HIAM_CHANGEKBDTYPE,0L,0L);
            else if (FKC_NONE(fsFlags))
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(' ',0));
            return MRFROMLONG(TRUE);    // consumed
            break;
        case VK_TAB:
            WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            if (FKC_NONE(fsFlags))
                {
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT('\t',0));
                return MPFROMLONG(TRUE);    // consumed
                } else {
                return MPFROMLONG(FALSE);
                }
            break;
        case VK_HOME:
        case VK_END:
        case VK_LEFT:
        case VK_UP:
        case VK_DOWN:
        case VK_PAGEUP:
        case VK_PAGEDOWN:
        case VK_PAGEDOWN + 0x90:
        case VK_DELETE:
            if ((fsFlags & KC_CHAR) && (FKC_NONE(fsFlags))) break;  // considering keypad
            if (hia->inbuf->newpos != HIABUF_NONE)
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            return MPFROMLONG(FALSE);
            break;
        case VK_ENTER:
        case VK_NEWLINE:
            if (hia->inbuf->newpos != HIABUF_NONE)
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            return MPFROMLONG(FALSE);   // not consumed
            break;
        case VK_RIGHT:
            if ((fsFlags & KC_CHAR) && (FKC_NONE(fsFlags))) break;   // considering keypad
            if (hia->inbuf->newpos != HIABUF_NONE)
                {
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
                return MRFROMLONG(TRUE);
                } else {
                return MRFROMLONG(FALSE);   // NOT consumed
                }
            break;
        case VK_BACKSPACE:
            if (hia->inbuf->newpos != HIABUF_NONE)
                {
                WinSendMsg(hwnd,HIAM_CANCELKEY,0L,0L);
                return MRFROMLONG(TRUE);
                } else {
                return MRFROMLONG(FALSE);
                }
            break;

        case VK_INSERT:
            if ((fsFlags & KC_CHAR) && (FKC_NONE(fsFlags))) break;   // considering keypad
            if (hia->inbuf->newpos != HIABUF_NONE)
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            if (FKC_NONE(fsFlags))
                {
                WinSendMsg(hwnd,HIAM_CHANGEINSERTMODE,0L,0L);
                return MRFROMLONG(TRUE);
                } else {
                return MRFROMLONG(FALSE);
                }
            break;

        case VK_ESC :
            WinSendMsg(hwnd,HIAM_CANCELBUF,0L,0L);

            return FALSE;

        case VK_SHIFT :
        case VK_CTRL :
        case VK_ALT :
            return FALSE;
        }   // switch

        WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );

        return FALSE;
        } // Virtualkey

    if(( fsFlags & ( KC_CTRL | KC_ALT )) || (ucChar < 32) || (ucChar > 127))
    {
        WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );
        return FALSE;
    }

    if (hia->hanmode == HCH_ENG)
        {
        HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(ucChar,0));
        return MRFROMLONG(TRUE);
        }

    if ((hia_iskeypadkey(ucScancode))&&(fsFlags & KC_CHAR))
        {
        WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
        HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(ucChar,0));
        return MRFROMLONG(TRUE);
        }

    ucChar = hia_transkey( fsFlags, ucScancode, ucChar );

    if (WinGetKeyState(HWND_DESKTOP,VK_CAPSLOCK))
        {
        if (fsFlags & KC_SHIFT)
            {
            ucChar = toupper(ucChar);
            } else {
            ucChar = tolower(ucChar);
            }
        }
    ckey = hia_convertkey(hia->kbdtype,ucChar);
    {
    HANCHAR completedHch;
    HANCHAR workingHch;
    if (ckey & 0x80)    // if hangul key
        {
        ULONG oldbufState = hia->inbuf->newpos;
        if (hia->kbdtype == HAN_KBD_2)
            completedHch = HIAAutomata2(hia,ckey);
            else
            completedHch = HIAAutomata3(hia,ckey);
        workingHch = SHORT1FROMMR(WinSendMsg(hwnd,HIAM_QUERYWORKINGHCH,0L,0L));

        if (completedHch)       // if hch completed
            {
            HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROM2SHORT(completedHch,workingHch));
            HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(completedHch,workingHch));
            if (workingHch)     // begin composition of new hch
                HIA_NotifyToConnected(hia,HIAN_COMPO_BEGIN,MPFROM2SHORT(completedHch,workingHch));

            } else {    // if hch not completed

            if (workingHch)     // if exist composing hch
            if (oldbufState)
                HIA_NotifyToConnected(hia,HIAN_COMPO_STEP,
                    MPFROM2SHORT(0,workingHch));
                else
                HIA_NotifyToConnected(hia,HIAN_COMPO_BEGIN,
                    MPFROM2SHORT(0,workingHch));
            }

        return MRFROMLONG(TRUE);    // consumed

        } else {  // !@#$%^&*() ,etc

        WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
        HIA_NotifyToConnected(hia,HIAN_INSERTHCH,
            MPFROM2SHORT(ckey,0));
        return MRFROMLONG(TRUE);    // consumed

        }
        }
    return MRFROMLONG(FALSE);    // not consumed
}
Example #4
0
 MRESULT EXPENTRY icqFrameWindow(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 {
    switch(msg)
    {
    case WM_DDE_INITIATEACK:
       return (MRESULT) icqDDEInitiateAck(hwnd, (HWND)mp1, (PDDEINIT)mp2);

    case WM_DDE_DATA:
       DBGMessage("WM_DDE_DATA");
       icqDDEData(hwnd, (PDDESTRUCT) mp2);
       break;

    case WM_CLOSE:
       DBGMessage("WM_CLOSE");
       close(hwnd);
       break;

    case WM_CREATE:
       icqskin_cfgWindow(hwnd,ICQFRAME,0);
       break;

    case WM_DESTROY:
       destroy(hwnd);
       break;

    case WM_ERASEBACKGROUND:
       erase(hwnd,(HPS) mp1, (PRECTL) mp2);
       break;

    case WM_SIZE:
       resize(hwnd,SHORT1FROMMP(mp2),SHORT2FROMMP(mp2));
       broadcast(hwnd,WMICQ_AUTOSIZE,0,0);
       break;

    case WM_PAINT:
       paint(hwnd);
       break;

    case WM_SETICON:
       WinSendMsg(WinQueryWindow(hwnd,QW_PARENT),msg,mp1,mp2);
       break;

    case WM_COMMAND:
       action(hwnd,SHORT1FROMMP(mp1), SHORT1FROMMP(mp2));
       break;

    case WM_PRESPARAMCHANGED:
       ppchanged(hwnd,LONGFROMMP(mp1));
       break;

    case WM_SETWINDOWPARAMS:
       return setparm(hwnd, PVOIDFROMMP(mp1), mp2);

    case WMICQ_SETNAME:
//       strncpy( ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->name, (const char *) mp1, 19);
       ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->name = (const char *) mp1;
       break;

    case WMICQ_SETICQHANDLE:
       DBGTracex(mp1);
       ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq = (HICQ) mp1;
       break;

    case WMICQ_GETICQHANDLE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq;

    case WMICQ_SETBUTTONTBL:
       setbuttons(hwnd,(const struct icqButtonTable *) mp1, (int) mp2);
       break;

    case WMICQ_QUERYPALLETE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->pal;

    case WMICQ_EVENT:  // MP1 = type,code,user  MP2 = parm
       event(hwnd,CHAR3FROMMP(mp1),CHAR4FROMMP(mp1),SHORT1FROMMP(mp1),(ULONG) mp2);
       break;

    case WMICQ_SELECTPAL:
       icqskin_loadPallete( (HPS) mp1, 0, ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->pal);
       break;

    case 0x041E:
       return WinDefWindowProc(hwnd, msg, mp1, mp2);

    case 0x041F:
       return WinDefWindowProc(hwnd, msg, mp1, mp2);

    case WM_BEGINDRAG:
       return beginDrag(hwnd, (POINTS *) &mp1);

    case WM_ENDDRAG:
       return endDrag(hwnd);

    case WM_TIMER:
       timer(hwnd);
       break;

#ifdef SKINNED_GUI
    case WMICQ_QUERYBGIMAGE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->bg;
#else
    case WMICQ_QUERYBGIMAGE:
       return (MRESULT) NO_IMAGE;
#endif

    case WM_OWNERPOSCHANGE:
       DBGMessage("WM_OWNERPOSCHANGE");
       return WinDefWindowProc(hwnd,msg,mp1,mp2);

    case WM_MOUSEMOVE:
       if(WinQueryCapture(HWND_DESKTOP) == hwnd);
          saveMouse(hwnd,SHORT1FROMMP(mp1),SHORT2FROMMP(mp1));
       return WinDefWindowProc(hwnd,msg,mp1,mp2);

    case WMICQ_CLEAR:
       clearSkin( (ICQFRAME *) WinQueryWindowPtr(hwnd,0));
       break;

    case WMICQ_LOADSKIN:
       loadSkin(hwnd,(const char *) mp1, (SKINFILESECTION *) mp2);
       break;

    case WMICQ_SKINCHILDS:
       loadSkin4Childs(hwnd,(const char *) mp1, (SKINFILESECTION *) mp2);
       break;

    case WMICQ_RESTORE:
       restoreWindow(hwnd,(const char *) mp1,SHORT1FROMMP(mp2),SHORT2FROMMP(mp2));
       break;

    case WMICQ_STORE:
       storeWindow(hwnd,(const char *) mp1);
       break;

    case WMICQ_CONFIGURE:
       configure(hwnd,(int) mp1);
       break;

    case WMICQ_SETMSGCHILD:
       createchild(hwnd, (const MSGCHILD *) mp1, SHORT1FROMMP(mp2));
       break;

    case WMICQ_SKINELEMENT:
       skinElement(hwnd,(HWND) mp1, (const char **) mp2);
       break;

    case WMICQ_DRAWCONTENTS:
       break;

    case WMICQ_AUTOSIZE:
       autoSize(hwnd);
       break;

    case WMICQ_SIZEBUTTONS:
       return (MRESULT) sizeButtonBar(hwnd,SHORT1FROMMP(mp1),SHORT2FROMMP(mp1),(const USHORT *) mp2);

    case WMICQ_INVALIDATE:
       DBGMessage("WMICQ_INVALIDATE");
       WinInvalidateRect(hwnd,NULL,TRUE);
       break;

    /*---[ SysTray ]--------------------------------------------*/

    case WM_BUTTON2CLICK | 0x2000:
       icqShowPopupMenu(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq, 0, ICQMNU_MODES, 0, 0);
       return (MRESULT) TRUE;

    case WM_BUTTON1CLICK | 0x2000:
       openMessage(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq);
       return (MRESULT) TRUE;

    case WM_TRAYEXIT:	// When tray exits/crashes, it posts WM_TRAYEXIT (0xCD20) to all tray windows.
       icqDisableSysTray(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq);
       return (MRESULT) TRUE;

    /*---[ Default window processing ]--------------------------*/

    default:
       return WinDefWindowProc(hwnd,msg,mp1,mp2);
    }
    return 0;
 }
Example #5
0
ULONG HEOptions(HWND hwnd)
{
HWND hwndDlg;
ULONG TextFormat = (ULONG) WinSendMsg(hwndHMLE,HMLM_QUERYTEXTFORMAT,0L,0L);
ULONG HanType   = (ULONG)  WinSendMsg(hwndHMLE,HMLM_QUERYHANTYPE,0L,0L);
ULONG ulrc = ( ULONG ) WinSendMsg( hwndHMLE, HMLM_QUERYWRAP, 0, 0 );
//int old_eoltype = TextFormat;
//int old_hantype = HanType;
BOOL wordWrap = CHAR3FROMMP( ulrc );
BOOL wordProtect = CHAR4FROMMP( ulrc );
int  wordWrapSize = SHORT1FROMMR( ulrc );
CHAR size[ 10 ];

    hwndDlg = WinLoadDlg(HWND_DESKTOP,hwnd,&WinDefDlgProc,NULLHANDLE,IDD_OPTIONS,NULL);

    if (TextFormat==HMLE_EOL_CRLF)
        WinSendMsg(WinWindowFromID(hwndDlg,IDB_TF_CRLF),BM_SETCHECK,MPFROMLONG(1L),0L);
        else
        WinSendMsg(WinWindowFromID(hwndDlg,IDB_TF_LF),BM_SETCHECK,MPFROMLONG(1L),0L);
    if (HanType==HMLE_HAN_KS)
        WinSendMsg(WinWindowFromID(hwndDlg,IDB_HT_KS),BM_SETCHECK,MPFROMLONG(1L),0L);
        else
        WinSendMsg(WinWindowFromID(hwndDlg,IDB_HT_SY),BM_SETCHECK,MPFROMLONG(1L),0L);

    WinSendMsg( WinWindowFromID( hwndDlg, IDB_WORDWRAP ), BM_SETCHECK,
                MPFROMLONG( SHORT1FROMMR( wordWrap )), 0 );

    _itoa( wordWrapSize, size, 10 );
    WinSetWindowText( WinWindowFromID( hwndDlg, IDEF_WORDWRAP_SIZE ), size );

    //WinSetFocus(HWND_DESKTOP,hwndDlg);

    ulrc = WinProcessDlg(hwndDlg);

    if (ulrc == DID_OK)
        {
        TextFormat  = (ULONG) WinSendMsg(WinWindowFromID(hwndDlg,IDB_TF_CRLF),BM_QUERYCHECKINDEX,0L,0L);
        HanType     = (ULONG) WinSendMsg(WinWindowFromID(hwndDlg,IDB_HT_KS),BM_QUERYCHECKINDEX,0L,0L);
        if (TextFormat == 1)
            {
            WinSendMsg(hwndHMLE,HMLM_SETTEXTFORMAT,MPFROMLONG(HMLE_EOL_CRLF),0L);
            WinPostMsg(hwndStatbar,STATBAR_USERM_SETEOLTYPE,MPFROMLONG(HMLE_EOL_CRLF),0L);
            } else {
            WinSendMsg(hwndHMLE,HMLM_SETTEXTFORMAT,MPFROMLONG(HMLE_EOL_LF),0L);
            WinPostMsg(hwndStatbar,STATBAR_USERM_SETEOLTYPE,MPFROMLONG(HMLE_EOL_LF),0L);
            }
        if (HanType == 1)
            {
            WinSendMsg(hwndHMLE,HMLM_SETHANTYPE,MPFROMLONG(HMLE_HAN_KS),0L);
            WinPostMsg(hwndStatbar,STATBAR_USERM_SETHANTYPE,MPFROMLONG(HMLE_HAN_KS),0L);
            } else {
            WinSendMsg(hwndHMLE,HMLM_SETHANTYPE,MPFROMLONG(HMLE_HAN_SY),0L);
            WinPostMsg(hwndStatbar,STATBAR_USERM_SETHANTYPE,MPFROMLONG(HMLE_HAN_SY),0L);
            }

        wordWrap = ( BOOL )WinSendDlgItemMsg( hwndDlg, IDB_WORDWRAP, BM_QUERYCHECK, 0, 0 );
        WinQueryWindowText( WinWindowFromID( hwndDlg, IDEF_WORDWRAP_SIZE ), sizeof( size ), size );
        wordWrapSize = atoi( size );
        if(( wordWrapSize != 0 ) && ( wordWrapSize < MIN_WORDWRAP_SIZE ))
            wordWrapSize = MIN_WORDWRAP_SIZE;

        WinSendMsg( hwndHMLE, HMLM_SETWRAP, MPFROM2SHORT( wordWrap, wordProtect ), MPFROMSHORT( wordWrapSize ));
        }
    WinDestroyWindow(hwndDlg);
    return 0L;
}
Example #6
0
MRESULT EXPENTRY FlyWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    SIZEL        sizl;
    int          rc, key, mou_r, mou_c, mou_ev, new_vio_rows, new_vio_cols;
    int          deltaX, deltaY, pix_rows, pix_cols, new_x0, new_y0;
    static int   mou_c1=-1, mou_r1=-1;
    struct _item *L;
    HWND         hwndMenu;
    SWP          swp;
    QMSG         *qmsg;
    USHORT       vk, fl;
    
    switch (msg)
    {
    case WM_CREATE:
        hdc = WinOpenWindowDC (hwnd);
        sizl.cx = sizl.cy = 0;
        grab_video ();
        hps = GpiCreatePS (hab, hdc, &sizl, PU_PELS | GPIF_DEFAULT |
                           GPIT_MICRO | GPIA_ASSOC);
        rc = VioCreatePS (&hvps, 80, 25, 0, 1, 0);
        VioGetDeviceCellSize (&cyChar, &cxChar, hvps);
        set_cursor (0);
        VioSetCurType (pci, hvps);
        release_video ();
        DosPostEventSem (hev_VideoReady);
        return 0;
        
    case WM_MOUSEMOVE:          mou_ev = MOUEV_MOVE; goto MOUSE;
    
    case WM_BUTTON1CLICK:       mou_ev = MOUEV_B1SC; goto MOUSE;
    case WM_BUTTON1DBLCLK:      mou_ev = MOUEV_B1DC; goto MOUSE;
    case WM_BUTTON1MOTIONSTART: mou_ev = MOUEV_B1MS; goto MOUSE;
    case WM_BUTTON1MOTIONEND:   mou_ev = MOUEV_B1ME; goto MOUSE;
    case WM_BUTTON1DOWN:        mou_ev = MOUEV_B1DN; goto MOUSE;
    case WM_BUTTON1UP:          mou_ev = MOUEV_B1UP; goto MOUSE;
    
    case WM_BUTTON2CLICK:       mou_ev = MOUEV_B2SC; goto MOUSE;
    case WM_BUTTON2DBLCLK:      mou_ev = MOUEV_B2DC; goto MOUSE;
    case WM_BUTTON2MOTIONSTART: mou_ev = MOUEV_B2MS; goto MOUSE;
    case WM_BUTTON2MOTIONEND:   mou_ev = MOUEV_B2ME; goto MOUSE;
    case WM_BUTTON2DOWN:        mou_ev = MOUEV_B2DN; goto MOUSE;
    case WM_BUTTON2UP:          mou_ev = MOUEV_B2UP; goto MOUSE;
    
    case WM_BUTTON3DBLCLK:      mou_ev = MOUEV_B3DC; goto MOUSE;
    case WM_BUTTON3CLICK:       mou_ev = MOUEV_B3SC; goto MOUSE;
    case WM_BUTTON3MOTIONSTART: mou_ev = MOUEV_B3MS; goto MOUSE;
    case WM_BUTTON3MOTIONEND:   mou_ev = MOUEV_B3ME; goto MOUSE;
    case WM_BUTTON3DOWN:        mou_ev = MOUEV_B3DN; goto MOUSE;
    case WM_BUTTON3UP:          mou_ev = MOUEV_B3UP; goto MOUSE;
    
    MOUSE:
        if (fl_opt.mouse_active != TRUE) break;
        mou_r = vio_rows - 1 - (SHORT2FROMMP (mp1)/cyChar);
        mou_c = SHORT1FROMMP (mp1)/cxChar;
        if (mou_r < 0 || mou_c < 0) break;
        // prevent MOUEV_MOVE message with same coordinates
        if (mou_ev == MOUEV_MOVE && mou_r == mou_r1 && mou_c == mou_c1) break;
        mou_r1 = mou_r, mou_c1 = mou_c;
        que_put (FMSG_BASE_MOUSE + FMSG_BASE_MOUSE_EVTYPE*mou_ev +
                 FMSG_BASE_MOUSE_X*mou_c + FMSG_BASE_MOUSE_Y*mou_r);
        break;
        
    case WM_PAINT:
        WinBeginPaint (hwnd, hps, NULL);
        grab_video ();
        VioShowBuf (0, 2 * vio_rows * vio_cols, hvps);
        release_video ();
        WinEndPaint (hps);
        return 0;

    case WM_CHAR:
        if (SHORT1FROMMP (mp1) & KC_KEYUP) return 0;
        if (SHORT2FROMMP (mp2) == VK_SHIFT ||
            SHORT2FROMMP (mp2) == VK_CTRL ||
            SHORT2FROMMP (mp2) == VK_ALT) return 0;
        key = pmkey2asvkey (SHORT2FROMMP(mp2), CHAR4FROMMP(mp1), SHORT1FROMMP(mp2),
                            CHAR3FROMMP(mp1), SHORT1FROMMP(mp1));
        if (key != -1) que_put (key);
        return 0;

    case WM_TRANSLATEACCEL:
        qmsg = (QMSG *)mp1;
        vk = SHORT2FROMMP (qmsg->mp2);
        fl = SHORT1FROMMP (qmsg->mp1) & (KC_ALT | KC_SHIFT | KC_CTRL | KC_KEYUP);
        if (vk == VK_MENU || vk == VK_F1) return FALSE;
        //if ((fl & KC_ALT) && vk >= VK_F1 && vk <= VK_F24) return FALSE;
        break;
        
    case WM_CLOSE:
        que_put (FMSG_BASE_SYSTEM +
                 FMSG_BASE_SYSTEM_TYPE*SYSTEM_QUIT);
        return 0;
        
    case WM_SIZE:
        if (cxChar != 0 && cyChar != 0)
        {
            pix_rows = SHORT2FROMMP (mp2);
            pix_cols = SHORT1FROMMP (mp2);
            new_vio_rows = pix_rows / cyChar;
            new_vio_cols = pix_cols / cxChar;
            if (new_vio_rows != vio_rows || new_vio_cols != vio_cols)
            {
                grab_video ();
                VioAssociate (0, hvps);
                VioDestroyPS (hvps);
                rc = VioCreatePS (&hvps, new_vio_rows, new_vio_cols, 0, 1, 0);
                VioSetDeviceCellSize (cyChar, cxChar, hvps);
                VioGetDeviceCellSize (&cyChar, &cxChar, hvps);
                rc = VioAssociate (hdc, hvps);
                VioSetCurType (pci, hvps);
                release_video ();
                que_put (FMSG_BASE_SYSTEM + FMSG_BASE_SYSTEM_TYPE*SYSTEM_RESIZE +
                         FMSG_BASE_SYSTEM_INT2*new_vio_rows + FMSG_BASE_SYSTEM_INT1*new_vio_cols);
            }
            deltaX = new_vio_cols*cxChar - pix_cols;
            deltaY = new_vio_rows*cyChar - pix_rows;
            //if (deltaX != 0 || deltaY != 0)
            if (abs(deltaX) > MAX_DELTA || abs(deltaY) > MAX_DELTA)
            {
                WinPostMsg (hwndFrame, WM_FLY_RESIZE,
                            MPFROM2SHORT (SHORTBASE+deltaX, SHORTBASE+deltaY), NULL);
            }
        }
        WinDefAVioWindowProc (hwnd, msg, (ULONG)mp1, (ULONG)mp2);
        return 0;

    case WM_COMMAND:
        que_put (FMSG_BASE_MENU + LOUSHORT (mp1));
        break;

    case WM_FLY_LOADMENU:
        L = PVOIDFROMMP (mp1);
        // obtain handle for window menu
        hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU);
        fill_submenu (hwndMenu, L);
        fly_active_menu = L;
        break;

    case WM_FLY_UNLOADMENU:
        L = PVOIDFROMMP (mp1);
        // obtain handle for window menu
        hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU);
        empty_submenu (hwndMenu, L);
        fly_active_menu = NULL;
        break;
        
    case WM_FLY_RESIZE:
        deltaX = SHORT1FROMMP (mp1) - SHORTBASE;
        deltaY = SHORT2FROMMP (mp1) - SHORTBASE;
        rc = WinQueryWindowPos (hwndFrame, &swp);
        rc = WinSetWindowPos (hwndFrame, 0, swp.x, swp.y-deltaY, swp.cx+deltaX, swp.cy+deltaY, SWP_SIZE|SWP_MOVE);
        break;
        
    case WM_FLY_MOVE_CANVAS:
        new_x0 = SHORT1FROMMP (mp1) - SHORTBASE;
        new_y0 = SHORT2FROMMP (mp1) - SHORTBASE;
        rc = WinQueryWindowPos (hwndFrame, &swp);
        WinSetWindowPos (hwndFrame, 0, new_x0, new_y0-swp.cy, 0, 0, SWP_MOVE);
        //DosPostEventSem (hev_VideoReady);
        break;
        
    case WM_FLY_MENU_CHSTATUS:
        hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU);
        WinEnableMenuItem (hwndMenu, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));
        item_status_change++;
        break;
        
    case WM_FLY_MENU_CHSTATE:
        hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU);
        WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (SHORT1FROMMP(mp1), TRUE),
                    MPFROM2SHORT (MIA_CHECKED, SHORT2FROMMP(mp1) ? MIA_CHECKED : 0));
        break;
        
    case WM_DESTROY:
        grab_video ();
        VioAssociate (0, hvps);
        VioDestroyPS (hvps);
        GpiDestroyPS (hps);
        release_video ();
        que_put (FMSG_BASE_SYSTEM +
                 FMSG_BASE_SYSTEM_TYPE*SYSTEM_DIE);
        return 0;
    }
    
    return WinDefWindowProc (hwnd, msg, mp1, mp2);
}
/*����������������������������������������������������������������������������*/
PSZ
MpFormat(MPARAM    mpValue,
         MP_FORMAT mpFormat,
         PSZ       pszWhere)
{
  /**************************************************************************
  * Local data
  **************************************************************************/
  CHAR    szC1[32],
          szC2[32],
          szC3[32],
          szC4[32];

  /**************************************************************************
  * Locate control data for this MP format specification
  **************************************************************************/
  PMPF_CONTROL pMPF = MpFind(mpFormat);

  /**************************************************************************
  * Process based on MP format specified
  **************************************************************************/
  switch(pMPF->mpMethod)
  {
    /**************************************************************************
    * Format as one 32 bit value
    **************************************************************************/
    case As_32:

         sprintf(pszWhere,
                 pMPF->pszFormat,

                 mpValue);
    break;

    /**************************************************************************
    * Format as two 16 bit values
    **************************************************************************/
    case As_16_16:

         MpFormat(mpValue, MP_32H, pszWhere);

         strcat(pszWhere, ": ");

         sprintf( pszWhere + strlen(pszWhere),
                  pMPF->pszFormat,

                  SHORT2FROMMP(mpValue),

                  SHORT1FROMMP(mpValue)
                );
    break;

    /**************************************************************************
    * Format as 16 bit and two 8 bit values
    **************************************************************************/
    case As_16_8_8:

         MpFormat(mpValue, MP_32H, pszWhere);

         strcat(pszWhere, ": ");

         sprintf( pszWhere + strlen(pszWhere),
                  pMPF->pszFormat,

                  SHORT2FROMMP(mpValue),

                  CHAR2FROMMP(mpValue),
                  CHAR1FROMMP(mpValue)
                );
    break;

    /**************************************************************************
    * Format as 16 bit and two character values
    **************************************************************************/
    case As_16_C_C:

         MpFormat(mpValue, MP_32H, pszWhere);

         strcat(pszWhere, ": ");

         sprintf( pszWhere + strlen(pszWhere),
                  pMPF->pszFormat,

                  SHORT2FROMMP(mpValue),

                  MpAsCharacter( CHAR2FROMMP(mpValue), szC1 ),
                  MpAsCharacter( CHAR1FROMMP(mpValue), szC2 )
                );
    break;

    /**************************************************************************
    * Format as two 8 bit and 16 bit values
    **************************************************************************/
    case As_8_8_16:

         MpFormat(mpValue, MP_32H, pszWhere);

         strcat(pszWhere, ": ");

         sprintf( pszWhere + strlen(pszWhere),
                  pMPF->pszFormat,

                  CHAR4FROMMP(mpValue),
                  CHAR3FROMMP(mpValue),

                  SHORT1FROMMP(mpValue)
                );
    break;

    /**************************************************************************
    * Format as two character and 16 bit values
    **************************************************************************/
    case As_C_C_16:

         MpFormat(mpValue, MP_32H, pszWhere);

         strcat(pszWhere, ": ");

         sprintf( pszWhere + strlen(pszWhere),
                  pMPF->pszFormat,

                  MpAsCharacter( CHAR4FROMMP(mpValue), szC1 ),
                  MpAsCharacter( CHAR3FROMMP(mpValue), szC2 ),

                  SHORT1FROMMP(mpValue)
                );
    break;

    /**************************************************************************
    * Format as four 8 bit values
    **************************************************************************/
    case As_8_8_8_8:

         MpFormat(mpValue, MP_32H, pszWhere);

         strcat(pszWhere, ": ");

         sprintf( pszWhere + strlen(pszWhere),
                  pMPF->pszFormat,

                  CHAR4FROMMP(mpValue),
                  CHAR3FROMMP(mpValue),

                  CHAR2FROMMP(mpValue),
                  CHAR1FROMMP(mpValue)
                );
    break;

    /**************************************************************************
    * Format as four character values
    **************************************************************************/
    case As_C_C_C_C:

         MpFormat(mpValue, MP_32H, pszWhere);

         strcat(pszWhere, ": ");

         sprintf( pszWhere + strlen(pszWhere),
                  pMPF->pszFormat,

                  MpAsCharacter( CHAR4FROMMP(mpValue), szC1 ),
                  MpAsCharacter( CHAR3FROMMP(mpValue), szC2 ),

                  MpAsCharacter( CHAR2FROMMP(mpValue), szC3 ),
                  MpAsCharacter( CHAR1FROMMP(mpValue), szC4 )
                );
    break;
  }

  /**************************************************************************
  * Return where formatted MP text went
  **************************************************************************/
  return(pszWhere);
}