Example #1
0
MRESULT mainwmCommand( HWND hwnd, MPARAM mp1, MPARAM mp2 )
{
    switch (SHORT1FROMMP(mp1))
    {
    case IDM_NEW:
        HENew(hwnd);
        break;
    case IDM_OPEN:
        HEOpen(hwnd);
//        WinSetFocus(HWND_DESKTOP,hwndHMLE);
        break;
    case IDM_IMPORT:
        HEImport(hwnd);
        break;
    case IDM_RELOAD:
        if (WinSendMsg(hwndHMLE,HMLM_QUERYCHANGED,0L,0L))
            {
            if (WinMessageBox(
                    HWND_DESKTOP,hwnd,
                    "Document changed. Discard it?","Caution",
                    0,MB_YESNO|MB_DEFBUTTON2|MB_WARNING|MB_MOVEABLE)==MBID_NO)
                return 0L;
            }
        HEReloadAfterChangeHanCode(hwnd);
        break;
    case IDM_QUICKRELOAD:
        HEReloadAfterChangeHanCode(hwnd);
        break;
    case IDM_SAVE:
        HESave(hwnd);
//        WinSetFocus(HWND_DESKTOP,hwndHMLE);
        break;
    case IDM_SAVEAS:
        HESaveAs(hwnd);
        break;
    case IDM_EXIT:
        HEExit(hwnd);
//        WinSetFocus(HWND_DESKTOP,hwndHMLE);
//        return 0L;
        break;
    case IDM_ABOUT:
        HEAbout(hwnd);
        break;
    case IDM_OPTIONS:
        HEOptions(hwnd);
        break;
    case IDM_COPY:
        WinSendMsg(hwndHMLE,HMLM_COPY,0,0);
//        WinSetFocus(HWND_DESKTOP,hwndHMLE);
        break;
    case IDM_CUT:
        WinSendMsg(hwndHMLE,HMLM_CUT,0,0);
//        WinSetFocus(HWND_DESKTOP,hwndHMLE);
        break;
    case IDM_PASTE:
        WinSendMsg(hwndHMLE,HMLM_PASTE,0,0);
        break;
    case IDM_CLEAR:
        WinSendMsg(hwndHMLE,HMLM_CLEAR,0,0);
//        WinSetFocus(HWND_DESKTOP,hwndHMLE);
        break;
    case IDM_FIND:
        HEFind(hwnd);
        break;
    case IDM_SELECTALL:
        HESelectAll(hwnd);
        break;
    case IDM_SPECIALCHARS:
        HESpecialChars( hwnd );
        break;
    case IDM_HANJA:
        HEHanja( hwnd );
        break;
    } // switch Control

    if( SHORT1FROMMP( mp2 ) == CMDSRC_PUSHBUTTON )
        WinSetFocus(HWND_DESKTOP,hwndHMLE);

    WinPostMsg( hwndHMLE, HMLM_REFRESH, 0, 0 );

    return MRFROMLONG(0L);
}
Example #2
0
static void PMThread( void *arg )
{
    vout_display_t *vd = ( vout_display_t * )arg;
    vout_display_sys_t * sys = vd->sys;
    ULONG i_frame_flags;
    QMSG qm;
    char *psz_mode;
    ULONG i_kva_mode;

    /* */
    video_format_t fmt = vd->fmt;

    /* */
    vout_display_info_t info = vd->info;
    info.is_slow = false;
    info.has_double_click = true;
    info.has_hide_mouse = false;
    info.has_pictures_invalid = false;

    MorphToPM();

    sys->hab = WinInitialize( 0 );
    sys->hmq = WinCreateMsgQueue( sys->hab, 0);

    WinRegisterClass( sys->hab,
                      WC_VLC_KVA,
                      WndProc,
                      CS_SIZEREDRAW | CS_MOVENOTIFY,
                      sizeof( PVOID ));

    sys->b_fixt23 = var_CreateGetBool( vd, "kva-fixt23");

    if( !sys->b_fixt23 )
    {
        vout_window_cfg_t wnd_cfg;

        wnd_cfg.is_standalone = false;
        wnd_cfg.type          = VOUT_WINDOW_TYPE_HWND;
        wnd_cfg.x             = var_InheritInteger(vd, "video-x");
        wnd_cfg.y             = var_InheritInteger(vd, "video-y");
        wnd_cfg.width         = vd->cfg->display.width;
        wnd_cfg.height        = vd->cfg->display.height;

        /* If an external window was specified, we'll draw in it. */
        sys->parent_window =
            vout_display_NewWindow( vd, &wnd_cfg );
    }

    if( sys->parent_window )
    {
        sys->parent = ( HWND )sys->parent_window->handle.hwnd;

        /* Workaround :
         * When an embedded window opened first, it is not positioned
         * correctly. So reposition it here, again.
         */
        WinSetWindowPos( WinQueryWindow( sys->parent, QW_PARENT ),
                         HWND_TOP, 0, 0, 0, 0, SWP_MOVE );

        ULONG i_style = WinQueryWindowULong( sys->parent, QWL_STYLE );
        WinSetWindowULong( sys->parent, QWL_STYLE,
                           i_style | WS_CLIPCHILDREN );

        i_frame_flags = FCF_TITLEBAR;
    }
    else
    {
        sys->parent = HWND_DESKTOP;

        i_frame_flags = FCF_SYSMENU    | FCF_TITLEBAR | FCF_MINMAX |
                        FCF_SIZEBORDER | FCF_TASKLIST;
    }

    sys->frame =
        WinCreateStdWindow( sys->parent,      /* parent window handle */
                            WS_VISIBLE,       /* frame window style */
                            &i_frame_flags,   /* window style */
                            WC_VLC_KVA,       /* class name */
                            "",               /* window title */
                            0L,               /* default client style */
                            NULLHANDLE,       /* resource in exe file */
                            1,                /* frame window id */
                            &sys->client );   /* client window handle */

    if( sys->frame == NULLHANDLE )
    {
        msg_Err( vd, "cannot create a frame window");

        goto exit_frame;
    }

    WinSetWindowPtr( sys->client, 0, vd );

    if( sys->b_fixt23 )
    {
        WinSetWindowPtr( sys->frame, 0, vd );
        sys->p_old_frame = WinSubclassWindow( sys->frame, MyFrameWndProc );
    }

    psz_mode = var_CreateGetString( vd, "kva-video-mode" );

    i_kva_mode = KVAM_AUTO;
    if( strcmp( psz_mode, "snap" ) == 0 )
        i_kva_mode = KVAM_SNAP;
    else if( strcmp( psz_mode, "wo" ) == 0 )
        i_kva_mode = KVAM_WO;
    else if( strcmp( psz_mode, "vman" ) == 0 )
        i_kva_mode = KVAM_VMAN;
    else if( strcmp( psz_mode, "dive" ) == 0 )
        i_kva_mode = KVAM_DIVE;

    free( psz_mode );

    if( kvaInit( i_kva_mode, sys->client, COLOR_KEY ))
    {
        msg_Err( vd, "cannot initialize KVA");

        goto exit_kva_init;
    }

    kvaCaps( &sys->kvac );

    msg_Dbg( vd, "selected video mode = %s",
             psz_video_mode[ sys->kvac.ulMode - 1 ]);

    if( OpenDisplay( vd, &fmt ) )
    {
        msg_Err( vd, "cannot open display");

        goto exit_open_display;
    }

    if( vd->cfg->is_fullscreen )
    {
        if( sys->parent_window )
            vout_window_SetFullScreen(sys->parent_window, true);
        else
            WinPostMsg( sys->client, WM_VLC_FULLSCREEN_CHANGE,
                        MPFROMLONG( true ), 0 );
    }

    kvaDisableScreenSaver();

    /* Setup vout_display now that everything is fine */
    vd->fmt     = fmt;
    vd->info    = info;

    vd->pool    = Pool;
    vd->prepare = NULL;
    vd->display = Display;
    vd->control = Control;
    vd->manage  = Manage;

    /* Prevent SIG_FPE */
    _control87(MCW_EM, MCW_EM);

    sys->i_result = VLC_SUCCESS;
    DosPostEventSem( sys->ack_event );

    while( WinGetMsg( sys->hab, &qm, NULLHANDLE, 0, 0 ))
        WinDispatchMsg( sys->hab, &qm );

    kvaEnableScreenSaver();

    CloseDisplay( vd );

    /* fall through */

exit_open_display :
    kvaDone();

exit_kva_init :
    if( sys->b_fixt23 )
        WinSubclassWindow( sys->frame, sys->p_old_frame );

    WinDestroyWindow( sys->frame );

exit_frame :
    vout_display_DeleteWindow( vd, sys->parent_window );

    if( sys->is_mouse_hidden )
        WinShowPointer( HWND_DESKTOP, TRUE );

    WinDestroyMsgQueue( sys->hmq );
    WinTerminate( sys->hab );

    sys->i_result = VLC_EGENERIC;
    DosPostEventSem( sys->ack_event );
}
Example #3
0
static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
    vout_display_t * vd = WinQueryWindowPtr( hwnd, 0 );
    MRESULT result = ( MRESULT )TRUE;

    if ( !vd )
        return WinDefWindowProc( hwnd, msg, mp1, mp2 );

    vout_display_sys_t * sys = vd->sys;
    RECTL rcl;
    SWP   swp;

    if ( sys->is_mouse_hidden &&
            ((msg >= WM_MOUSEFIRST    && msg <= WM_MOUSELAST) ||
             (msg >= WM_EXTMOUSEFIRST && msg <= WM_EXTMOUSELAST) ||
             msg == WM_MOUSELEAVE))
    {
        WinShowPointer(HWND_DESKTOP, TRUE);
        sys->is_mouse_hidden = false;
    }

    switch( msg )
    {
    /* the user wants to close the window */
    case WM_CLOSE:
        vout_display_SendEventClose(vd);
        result = 0;
        break;

    case WM_MOUSEMOVE :
    {
        SHORT i_mouse_x = SHORT1FROMMP( mp1 );
        SHORT i_mouse_y = SHORT2FROMMP( mp1 );
        RECTL movie_rect;
        int   i_movie_width, i_movie_height;
        int   i_src_width, i_src_height;

        /* Get a current movie area */
        kvaAdjustDstRect( &sys->kvas.rclSrcRect, &movie_rect );
        i_movie_width = movie_rect.xRight - movie_rect.xLeft;
        i_movie_height = movie_rect.yTop - movie_rect.yBottom;

        i_src_width =  sys->kvas.rclSrcRect.xRight -
                       sys->kvas.rclSrcRect.xLeft;
        i_src_height = sys->kvas.rclSrcRect.yBottom -
                       sys->kvas.rclSrcRect.yTop;

        int x = ( i_mouse_x - movie_rect.xLeft ) *
                i_src_width / i_movie_width +
                sys->kvas.rclSrcRect.xLeft;
        int y = ( i_mouse_y - movie_rect.yBottom ) *
                i_src_height / i_movie_height;

        /* Invert Y coordinate and add y offset */
        y = ( i_src_height - y ) + sys->kvas.rclSrcRect.yTop;;

        vout_display_SendEventMouseMoved(vd, x, y);

        result = WinDefWindowProc( hwnd, msg, mp1,mp2 );
        break;
    }

    case WM_BUTTON1DOWN :
        MousePressed( vd, hwnd, MOUSE_BUTTON_LEFT );
        break;

    case WM_BUTTON2DOWN :
        MousePressed( vd, hwnd, MOUSE_BUTTON_RIGHT );
        break;

    case WM_BUTTON3DOWN :
        MousePressed( vd, hwnd, MOUSE_BUTTON_CENTER );
        break;

    case WM_BUTTON1UP :
        MouseReleased( vd, MOUSE_BUTTON_LEFT );
        break;

    case WM_BUTTON2UP :
        MouseReleased( vd, MOUSE_BUTTON_RIGHT );
        break;

    case WM_BUTTON3UP :
        MouseReleased( vd, MOUSE_BUTTON_CENTER );
        break;

    case WM_BUTTON1DBLCLK :
        vout_display_SendEventMouseDoubleClick(vd);
        break;

    case WM_TRANSLATEACCEL :
        /* We have no accelerator table at all */
        result = ( MRESULT )FALSE;
        break;

    case WM_CHAR :
    {
        USHORT i_flags = SHORT1FROMMP( mp1 );
        USHORT i_ch    = SHORT1FROMMP( mp2 );
        USHORT i_vk    = SHORT2FROMMP( mp2 );
        int    i_key   = 0;

        /* If embedded window, let the parent process keys */
        if( sys->parent_window )
        {
            WinPostMsg( sys->parent, msg, mp1, mp2 );
            break;
        }

        if( !( i_flags & KC_KEYUP ))
        {
            if( i_flags & KC_VIRTUALKEY )
                /* convert the key if possible */
                i_key = ConvertKey( i_vk );
            else if(( i_flags & KC_CHAR ) && !HIBYTE( i_ch ))
                i_key = tolower( i_ch );

            if( i_key )
            {
                if( i_flags & KC_SHIFT )
                    i_key |= KEY_MODIFIER_SHIFT;

                if( i_flags & KC_CTRL )
                    i_key |= KEY_MODIFIER_CTRL;

                if( i_flags & KC_ALT )
                    i_key |= KEY_MODIFIER_ALT;

                vout_display_SendEventKey(vd, i_key);
            }
        }
        break;
    }

    /* Process Manage() call */
    case WM_VLC_MANAGE :
        break;

    /* Fullscreen change */
    case WM_VLC_FULLSCREEN_CHANGE :
        if( LONGFROMMP( mp1 ))
        {
            WinQueryWindowPos( sys->frame, &swp );
            sys->client_rect.xLeft   = swp.x;
            sys->client_rect.yBottom = swp.y;
            sys->client_rect.xRight  = sys->client_rect.xLeft   + swp.cx;
            sys->client_rect.yTop    = sys->client_rect.yBottom + swp.cy;
            WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE );

            rcl.xLeft   = 0;
            rcl.yBottom = 0;
            rcl.xRight  = sys->i_screen_width;
            rcl.yTop    = sys->i_screen_height;
        }
        else
            rcl = sys->client_rect;

        WinCalcFrameRect( sys->frame, &rcl, FALSE );

        WinSetWindowPos( sys->frame, HWND_TOP,
                         rcl.xLeft, rcl.yBottom,
                         rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom,
                         SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_SHOW |
                         SWP_ACTIVATE );
        break;

    /* Size change */
    case WM_VLC_SIZE_CHANGE :
        rcl.xLeft   = 0;
        rcl.yBottom = 0;
        rcl.xRight  = LONGFROMMP( mp1 );
        rcl.yTop    = LONGFROMMP( mp2 );
        WinCalcFrameRect( sys->frame, &rcl, FALSE );

        WinSetWindowPos( sys->frame, NULLHANDLE,
                         0, 0,
                         rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom,
                         SWP_SIZE );

        WinQueryWindowPos( sys->frame, &swp );
        sys->client_rect.xLeft   = swp.x;
        sys->client_rect.yBottom = swp.y;
        sys->client_rect.xRight  = sys->client_rect.xLeft   + swp.cx;
        sys->client_rect.yTop    = sys->client_rect.yBottom + swp.cy;
        WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE );
        break;

    default :
        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    }

    /* If embedded window, we need to change our window size according to a
     * parent window size */
    if( sys->parent_window )
    {
        WinQueryWindowRect( sys->parent, &rcl );

        if( rcl.xLeft   != sys->parent_rect.xLeft   ||
                rcl.yBottom != sys->parent_rect.yBottom ||
                rcl.xRight  != sys->parent_rect.xRight  ||
                rcl.yTop    != sys->parent_rect.yTop)
        {
            sys->parent_rect = rcl;

            WinCalcFrameRect( sys->frame, &rcl, FALSE );

            WinSetWindowPos( sys->frame, NULLHANDLE,
                             rcl.xLeft, rcl.yBottom,
                             rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom,
                             SWP_SIZE | SWP_MOVE );
        }
    }

    return result;
}
Example #4
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;
}
/* This Proc handles the ISO image mounting */
MRESULT EXPENTRY unmountIsoDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  char text[CCHMAXPATH];
  char title[CCHMAXPATH];

  ULONG rc;
  SWCNTRL swctl;
  PID pid;

  switch (msg)
    {      
    case WM_INITDLG:
      {
        BOOL bDone=FALSE;
        int i;

        writeLog("Initializing dialog...\n");  
        
        /* Add switch entry */
        memset(&swctl,0,sizeof(swctl));
        WinQueryWindowProcess(hwnd,&pid,NULL);
        swctl.hwnd=hwnd;
        swctl.uchVisibility=SWL_VISIBLE;
        swctl.idProcess=pid;
        swctl.bProgType=PROG_DEFAULT;
        swctl.fbJump=SWL_JUMPABLE;
        WinAddSwitchEntry(&swctl);
        
        /*sprintf(text,"%d",params[4]);*/ 
        // sprintf(text,"params[1]: %s ",params[1]);
        /* WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, pvSharedMem,
           params[4],
           0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
           WinPostMsg(hwnd,WM_CLOSE,0,0);
           return (MRESULT) TRUE;
           */
        
        /* Get free drive letters */
        if((rc=DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap))!=NO_ERROR)
          WinPostMsg(hwnd,WM_CLOSE,0,0);

        DosError(FERR_DISABLEHARDERR);

        for(i=2;i<26;i++) {
          if(( (ulDriveMap << (31-i)) >>31)) {
            char chrDrive[3]="A:";
            BYTE fsqBuf2[sizeof(FSQBUFFER2)+3*CCHMAXPATH]={0};
            PFSQBUFFER2 pfsqBuf2=(PFSQBUFFER2) &fsqBuf2;
            ULONG ulLength;

            /* Get FS */
            chrDrive[0]='A'+i;
            ulLength=sizeof(fsqBuf2);
            if(DosQueryFSAttach(chrDrive,0L,FSAIL_QUERYNAME, (PFSQBUFFER2)&fsqBuf2, &ulLength)==NO_ERROR) {
              if(!strcmp(pfsqBuf2->szName+pfsqBuf2->cbName+1,"ISOFS")) {
                FSINFO fsInfo;

                if(DosQueryFSInfo(i+1, FSIL_VOLSER, &fsInfo,sizeof(fsInfo))==NO_ERROR)
                  sprintf(text, "%s      (%s)",chrDrive,  fsInfo.vol.szVolLabel); 
                else
                  sprintf(text, "%s      (unknown)",chrDrive); 
                WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_INSERTITEM,MPFROMSHORT(LIT_END),MPFROMP(text));
              }
            }
            else
              printf("%s %s\n",chrDrive, "---"); 
          }
        }
        DosError(FERR_ENABLEHARDERR);

        /* Set dialog font to WarpSans for Warp 4 and above */
        if(cwQueryOSRelease()>=40) {
          WinSetPresParam(hwnd,
                          PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
                          DEFAULT_DIALOG_FONT );
        }
        
        if(!bHaveWindowPos)
          WinSetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_ZORDER|SWP_ACTIVATE);
        else
          WinSetWindowPos(hwnd,HWND_TOP,swpWindow.x, swpWindow.y, 0, 0, SWP_MOVE|SWP_ZORDER|SWP_ACTIVATE|SWP_SHOW);
        
        return (MRESULT) TRUE;
      }
    case WM_CLOSE:
      WinQueryWindowPos(hwnd,&swpWindow);
      WinDismissDlg(hwnd,0);
      return FALSE;
    case WM_HELP:
      sendCommand("DISPLAYHELPPANEL=5100");      
      break;
    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1))
        {
        case IDPB_UNMOUNT:
          {
            /* User pressed the Unount button */
            AEFS_DETACH detachparms={0};
            char pszDrive[3]={0};
            HOBJECT hObject;
            SHORT sSelected;
            memset(&detachparms, 0, sizeof(detachparms));

            /* Get the drive letter */
            sSelected=SHORT1FROMMR(WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_QUERYSELECTION,
                                             MPFROMSHORT(LIT_FIRST),MPFROMLONG(0L)));
            if(sSelected==LIT_NONE)
              break;

            WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_QUERYITEMTEXT,
                       MPFROM2SHORT(sSelected,2),MPFROMP(pszDrive));

            /* Send the attachment request to the FSD. */
            rc = DosFSAttach(
                             //                             (PSZ) "",
                             (PSZ) pszDrive,
                             (PSZ) AEFS_IFS_NAME,
                             &detachparms,
                             sizeof(detachparms),
                             FS_DETACH);
            if (rc) {
              DosBeep(100,400);             
                            
              sprintf(text, "Error while unmounting rc=%d. Make sure there're no open files on the drive.\n", rc);
              WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, text,
                             "ISO image unmount error",
                             0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
            }else {
              WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_DELETEITEM,
                         MPFROMSHORT(sSelected),MPFROMLONG(0L));
              sSelected=SHORT1FROMMR(WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_QUERYITEMCOUNT,
                                                MPFROMLONG(0L),MPFROMLONG(0L)));
              if(sSelected==0)
                WinEnableWindow(WinWindowFromID(hwnd,IDPB_UNMOUNT), FALSE);
            }

            break;
          }
        case IDPB_UNMOUNTCLOSE:
          WinPostMsg(hwnd,WM_CLOSE,0,0);
          break;
        default:
          break;
        }
      return (MRESULT) FALSE;
    default:
      break;
    }
  return WinDefDlgProc(hwnd, msg, mp1, mp2);    
}
int main(int argc, char * argv[])
{
	int i;
	char cmdLine[CCHMAXPATH*4]={0};
	char cmdLineBuff[CCHMAXPATH*4];
	char * chrPtr;
	HWND hwndNotify;
	char exeName[CCHMAXPATH];//"g:\\projects_working\\audiocpy\\show.exe";
	char chrError[CCHMAXPATH];
	char logName[CCHMAXPATH];
	RESULTCODES resultCodes;
	ULONG rc,ulAction;
	HFILE hf,hfNew;

    if(argc<3) {
      message();
      exit(-1);
    }
	
    hwndNotify=atol(argv[1]);

	sprintf(exeName,"%s",argv[2]);
	sprintf(logName,"%s\\Logfiles\\write.log",argv[3]);
	
	sprintf(cmdLine,exeName);
	chrPtr=strrchr(cmdLine,0);
	chrPtr++;

	/* Build parameters */
    for(i=4;i<argc;i++) {
      sprintf(cmdLineBuff,"%s",chrPtr);
      sprintf(chrPtr,"%s %s",cmdLineBuff,argv[i]);
    }
    /* Replace ' with " */
    changeChar(chrPtr,'\'','\"');

    /* Replace ^ with space */
    changeChar(chrPtr,'^',' ');

	printf("HWND: %ld",hwndNotify);
	printf("\n");	
	printf("cdrecord-executable: %s",exeName);
	printf("\n");
	printf("Logname: %s\n",logName);
	printf("cdrecord parameter: %s",chrPtr);
	printf("\n");

	/* Redirect stderr */
    rc=DosOpen(logName,&hf,&ulAction,0,FILE_NORMAL,OPEN_ACTION_CREATE_IF_NEW|OPEN_ACTION_OPEN_IF_EXISTS,
               OPEN_ACCESS_WRITEONLY|OPEN_SHARE_DENYWRITE,0);
	if(!rc) {
		DosSetFilePtr(hf,0,FILE_END,&ulAction);
		hfNew=2;
		DosDupHandle(hf,&hfNew);
		
		sprintf(logName,"---------------------------------------------------------------------\n");
		write(2,logName,strlen(logName));

		sprintf(logName,"\n");
		write(2,logName,strlen(logName));	
        
		/*	time(&ltime);		
		sprintf(logName,"%s",ctime(&ltime));
		write(2,logName,strlen(logName));	
		sprintf(logName,"\n");
		write(2,logName,strlen(logName));	*/
    
		sprintf(logName,"Starting to write using %s\n",exeName);
		write(2,logName,strlen(logName));
		
		sprintf(logName,"with the following parameters: %s\n",chrPtr);
		write(2,logName,strlen(logName));
	}
	
	DosExecPgm(chrError,sizeof(chrError),EXEC_SYNC,cmdLine,0,&resultCodes,exeName);
	sprintf(logName,"Return code is: %ld\n ",resultCodes.codeResult);
	write(2,logName,strlen(logName));

    DosClose(hf);
    WinPostMsg(hwndNotify,WM_APPTERMINATENOTIFY,MPFROMLONG(ACKEY_WRITEONLY),MPFROMLONG(resultCodes.codeResult));
    return 0;
}
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY Keyboard_FireFox_WndProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 // Указатель на страницу.
 PPAGE Page = Enhancer.Pages.Keyboard_ffx;

 // Проверяем сообщение.
 switch( Message )
  {
   // Отображаем настройки.
   case SM_SHOW_SETTINGS:
    {
     BYTE Value = 0; if( KeyMapper.Settings.Define_Dash ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_FireFox.Settings.Dash, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( KeyMapper.Settings.Define_Ctrl_Dash ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_FireFox.Settings.Ctrl_Dash, BM_SETCHECK, MPFROMLONG( Value ), 0 );
    }
   return 0;

   // Проверяем другие настройки.
   case SM_CHECK_OTHER_SETTINGS:
    {
     CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
     HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

     if( Ini_file )
      {
       ULONG Byte = 0; ULONG Byte_data = 0;
       ULONG CopyPaste_keys_in_VIO = 0; ULONG Mouse_in_VIO = 0;

       Byte = sizeof( BYTE ); if( PrfQueryProfileData( Ini_file, "Settings", INI_CLIPPER_VIO_COPYPASTE, &Byte_data, &Byte ) ) CopyPaste_keys_in_VIO = Byte_data;
       Byte = sizeof( BYTE ); if( PrfQueryProfileData( Ini_file, "Settings", INI_CLIPPER_VIO_MOUSE, &Byte_data, &Byte ) ) Mouse_in_VIO = Byte_data;

       if( !CopyPaste_keys_in_VIO && !Mouse_in_VIO ) WinEnableControl( Window, Keyboard_FireFox.Settings.Dash, 0 );
      }
    }
   return 0;

   // Следим за полями ввода.
   case WM_CONTROL:
    {
     ULONG WM_Control_Window_ID = SHORT1FROMMP( First_parameter );
     ULONG WM_Control_Action_ID = SHORT2FROMMP( First_parameter );

     if( WM_Control_Window_ID == Keyboard_FireFox.Settings.Dash )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) KeyMapper.Settings.Define_Dash = 0;
           else KeyMapper.Settings.Define_Dash = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Keyboard_FireFox.Settings.Ctrl_Dash )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) KeyMapper.Settings.Define_Ctrl_Dash = 0;
           else KeyMapper.Settings.Define_Ctrl_Dash = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }
    }
   return 0;

   // Обрабатываем нажатия на кнопки.
   case WM_COMMAND:
    {
     ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter );

     if( WM_Control_Button_ID == OK_BUTTON_ID )
      {
       CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
       HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

       if( Ini_file )
        {
         PrfWriteProfileData( Ini_file, "Settings", "Define Dash", &KeyMapper.Settings.Define_Dash, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Define Ctrl + Dash", &KeyMapper.Settings.Define_Ctrl_Dash, sizeof( BYTE ) );

         PrfCloseProfile( Ini_file );

         BroadcastRSMessages();
         NiceReadSettings();
        }
      }

     if( WM_Control_Button_ID == PD_BUTTON_ID )
      {
       if( Page->SetDefSettings ) Page->SetDefSettings( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext1 ) Page->SetDefSettings_Ext1( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext2 ) Page->SetDefSettings_Ext2( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext3 ) Page->SetDefSettings_Ext3( Page->Settings_to_show );

       WinPostMsg( Window, WM_COMMAND, (MPARAM) OK_BUTTON_ID, 0 );
      }

     if( WM_Control_Button_ID == HP_BUTTON_ID )
      {
       Help( Page->Settings_to_show, Enhancer.Code_page );
      }
    }
   return 0;
  }

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}
// ------------------------------------------------------------------------------------------------------------
MRESULT EXPENTRY ClientWinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  BOOL                fOK;
  RECTL               rectl;
  SIZEL               sizel;
  HPS                 hps;

  switch( msg ) {
  case WM_CLOSE:
    globals.fCloseMsgSent = TRUE;
    WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
    WinPostMsg( globals.hwndObject, WM_QUIT, 0, 0 );
    return 0;
  case WM_COMMAND:
    switch( SHORT1FROMMP( mp1 )) {
    case ID_RUN:
      WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
      WinInvalidateRect( hwnd, NULL, FALSE );
      WinPostMsg( globals.hwndObject, WM_USER_START_REXX, (MPARAM)hwnd, 0 );
      break;
    }
    return 0;
  case WM_CREATE:
    // disable client window until application initializes
    WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
    globals.hwndFrame    = WinQueryWindow( hwnd, QW_PARENT );
    globals.hwndTitlebar = WinWindowFromID( globals.hwndFrame, FID_TITLEBAR );
    globals.hwndMenubar  = WinWindowFromID( globals.hwndFrame, FID_MENU );
    // create title bar text; set into title bar
    sprintf( globals.szCaption, "%s - %s", CAPTION, globals.szRexxFileName );
    WinSetWindowText( globals.hwndTitlebar, globals.szCaption );
    // get window DC
    globals.hdcScreen = WinOpenWindowDC( hwnd );
    assert( globals.hdcScreen );
    // create a normal PS for the screen; coordinate system is 1/100 inch per unit of measure
    sizel.cx = sizel.cy = 0;
    globals.hpsScreen = GpiCreatePS( globals.hab, globals.hdcScreen, &sizel, PU_LOENGLISH | GPIF_LONG | GPIT_NORMAL | GPIA_ASSOC );
    assert( globals.hpsScreen );
    // object window operates on thread 2
    globals.tidObject = _beginthread( threadmain, NULL, LEN_STACK, NULL );
    assert( globals.tidObject );
    return 0;
  case WM_MOUSEMOVE:
    WinSetPointer( HWND_DESKTOP, WinQuerySysPointer( HWND_DESKTOP, globals.fBusy ? SPTR_WAIT:SPTR_ARROW, FALSE ));
    return (MRESULT)1;
  case WM_PAINT:
    hps = WinBeginPaint( hwnd, globals.hpsScreen, &rectl );
    fOK = WinFillRect( hps, &rectl, SYSCLR_WINDOW );
    assert( fOK );
    if( !globals.fBusy ) {
      // playback the retained GPI drawing orders
      GpiDrawChain( globals.hpsScreen );
    }
    WinEndPaint( hps );
    return 0;
  case WM_USER_ACK:
    // object window has posted ack; re-enable the window
    WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, 0, 0 );
    return 0;
  case WM_USER_DISABLE_CLIENT:
    globals.fBusy = TRUE;
    WinEnableWindow( globals.hwndClient, FALSE );
    WinEnableMenuItem( globals.hwndMenubar, ID_RUN, FALSE );
    return 0;
  case WM_USER_ENABLE_CLIENT:
    globals.fBusy = FALSE;
    WinEnableWindow( globals.hwndClient, TRUE );
    WinEnableMenuItem( globals.hwndMenubar, ID_RUN, TRUE );
    return 0;
  }
  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}
Example #9
0
MRESULT EXPENTRY O_CONFIGDlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  PO_CONFIGFORMINFO pO_CONFIGFormInfo=(PO_CONFIGFORMINFO) WinQueryWindowULong(hwndDlg, QWL_USER);
  HWND hwndFrame = hwndDlg;
 /* ##START Form.37 Top of window procedure */
 /* ##END Top of window procedure */
   switch (msg) {
   /* Form event Opened WM_INITDLG */
   case WM_INITDLG :
     if (mp2==0)
        mp2 = (MPARAM) malloc(sizeof(O_CONFIGFORMINFO));
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
     pO_CONFIGFormInfo=(PO_CONFIGFORMINFO) WinQueryWindowULong(hwndDlg, QWL_USER);
      WinAssociateHelpInstance(pMainFormInfo->hwndHelpInstance, hwndFrame);

      {
      /* ##START Form.1  */
      /* Event Opened - Form STICKY2\O_CONFIG */
      CHAR aTextValue[255]="text";
      LONG anIntegerValue=0;
      ULONG anUnsignedValue=0;

      c_cas = c_car = c_pop = c_aus = c_beep = c_mini = c_clr = 0;

      WinCheckButton(hwndDlg, SEND_CONFIG, CheckYes(gAfterSend));
      WinCheckButton(hwndDlg, REPLY_CONFIG, CheckYes(gAfterReply));
      WinCheckButton(hwndDlg, BACKGROUND_CONFIG, CheckYes(gPUS));
      WinCheckButton(hwndDlg, SURE_CONFIG, CheckYes(gSure));
      WinCheckButton(hwndDlg, MINI_CONFIG, CheckYes(gStickyIcon));

      WinCheckButton(hwndDlg, BEEP_CONFIG, CheckYes(gBeep));

      if (CheckNo(gBeep))
      {

      WinEnableControl(hwndDlg, 1006, FALSE);
      WinEnableControl(hwndDlg, 1007, FALSE);
      WinEnableControl(hwndDlg, FREQUENCY_CONFIG, FALSE);
      WinEnableControl(hwndDlg, DURATION_CONFIG, FALSE);

      } /* end if */


      /* Set range (numeric style) FREQUENCY_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, FREQUENCY_CONFIG,
                        SPBM_SETLIMITS,
                        MPFROMLONG(5000),                  /* Upper limit */
                        MPFROMLONG(10));                   /* Lower limit */ 
      WinSendDlgItemMsg(hwndDlg, DURATION_CONFIG,
                        SPBM_SETLIMITS,
                        MPFROMLONG(1000),                  /* Upper limit */
                        MPFROMLONG(10));                   /* Lower limit */ 

      WinSendDlgItemMsg(hwndDlg, FREQUENCY_CONFIG,
                        SPBM_SETCURRENTVALUE,
                        MPFROMLONG(atol(gFreq)), /* Value within range */
                        0);

      WinSendDlgItemMsg(hwndDlg, DURATION_CONFIG,
                        SPBM_SETCURRENTVALUE,
                        MPFROMLONG(atol(gDur)), /* Value within range */
                        0);


      /* Set range without update CLEAR_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, CLEAR_CONFIG,
                        SPBM_OVERRIDESETLIMITS,
                        MPFROMLONG(120),         /* Upper limit */
                        MPFROMLONG(0));          /* Lower limit */

      /* Set item value (numeric style) CLEAR_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, CLEAR_CONFIG,
                        SPBM_SETCURRENTVALUE,
                        MPFROMLONG(atol(gClearAuto)), /* Value within range */
                        0);
      /* ##END  */
      }
      break;

   /* Form event Closed WM_CLOSE */
   case WM_CLOSE :
      {
      /* ##START Form.2  */
      /* Event Closed - Form STICKY2\O_CONFIG */
      CHAR aTextValue[255]="text";
      LONG anIntegerValue=0;
      ULONG anUnsignedValue=0;


      MsgLog("Closing O_CONFIG");

      if (c_mini)
      {
      SWP swp;
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,MINI_CONFIG);
        
        strcpy(gStickyIcon, anUnsignedValue ? gYes : gNo);  
        PutString(S_StickyIcon, gStickyIcon); 
        WinQueryWindowPos(gHwndFrame, &swp);
        if (swp.fl & SWP_RESTORE)
           {
           MsgLog("O_CONFIG - RESTORE");
           WinPostMsg(gHwndFrame, WM_USER_RESTORE, 0, 0);
           }
       

      } /* end if */

      if (c_cas)
      {
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,SEND_CONFIG);

        strcpy(gAfterSend, anUnsignedValue ? gYes : gNo);  
        PutString(S_CloseAfterSend, gAfterSend); 
      } /* end if */
      if (c_car)
      {
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,REPLY_CONFIG);
        strcpy(gAfterReply, anUnsignedValue ? gYes: gNo );  
        PutString(S_CloseAfterReply, gAfterReply); 

      } /* end if */
      if (c_pop)
      {
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,BACKGROUND_CONFIG);
        strcpy(gPUS, anUnsignedValue ? gYes: gNo );  
        PutString(S_PopUpSticky, gPUS); 

          
      } /* end if */
      if (c_aus)
      {
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,SURE_CONFIG);
        
         strcpy(gSure, anUnsignedValue ? gYes : gNo );
         PutString(S_AreYouSure, gSure ); 

        
      } /* end if */
      if (c_beep)
      {
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,BEEP_CONFIG);
        
        PutString(S_Beep, anUnsignedValue ? gYes: gNo ); 
        strcpy(gBeep, anUnsignedValue ? gYes : gNo);
        
      } /* end if */
      /* Get item value (numeric style) FREQUENCY_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, FREQUENCY_CONFIG,
                        SPBM_QUERYVALUE,
                        MPFROMP(&anUnsignedValue),   /* Buffer for value */
                        MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE));
      if (atol(gFreq) != anUnsignedValue)
      {
        sprintf(gFreq, "%d", anUnsignedValue);
        PutString(S_Frequency, gFreq);
      } /* end if */
                        

      /* Get item value (numeric style) DURATION_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, DURATION_CONFIG,
                        SPBM_QUERYVALUE,
                        MPFROMP(&anUnsignedValue),   /* Buffer for value */
                        MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE));
      if (atol(gDur) != anUnsignedValue)
      {
        sprintf(gDur, "%d", anUnsignedValue);
        PutString(S_Duration, gDur);
      } /* end if */

      /* Get item value (numeric style) DURATION_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, CLEAR_CONFIG,
                        SPBM_QUERYVALUE,
                        MPFROMP(&anUnsignedValue),   /* Buffer for value */
                        MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE));
      if (atol(gClearAuto) != anUnsignedValue)
      {
        sprintf(gClearAuto, "%d", anUnsignedValue);
        PutString(S_ClearAuto, gClearAuto);
      } /* end if */
      /* ##END  */
      }
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
      break;

   /* Form event Destroyed WM_DESTROY */
   case WM_DESTROY :
      /* ##START Form.3  */
      /* ##END  */
     /* Remove help instance */
     WinAssociateHelpInstance((HWND) 0, hwndFrame);
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
      break;

   case WM_COMMAND :
      switch (SHORT1FROMMP(mp1)) {
      } /* end switch */
      break;

   case WM_CONTROL :
      switch (SHORT1FROMMP(mp1)) {
      /* Check Box SEND_CONFIG Event Handlers */
      case SEND_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1000.0  */
            /* Event Clicked/Selected - Close window after Send SEND_CONFIG */

            c_cas = 1;
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      /* Check Box REPLY_CONFIG Event Handlers */
      case REPLY_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1001.0  */
            /* Event Clicked/Selected - Close Window after Reply REPLY_CONFIG */

            c_car = 1;
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      /* Check Box BACKGROUND_CONFIG Event Handlers */
      case BACKGROUND_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1002.0  */
            /* Event Clicked/Selected - Popup Sticky on Receive BACKGROUND_CONFIG */
            c_pop = 1;
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      /* Check Box BEEP_CONFIG Event Handlers */
      case BEEP_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1003.0  */
            /* Event Clicked/Selected - Beep BEEP_CONFIG */
            ULONG	anUnsignedValue;

            c_beep = 1;
            /* Is button selected? BEEP_CONFIG Check Box */
            anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,BEEP_CONFIG);

            WinEnableControl(hwndDlg, 1006, anUnsignedValue);
            WinEnableControl(hwndDlg, 1007, anUnsignedValue);
            WinEnableControl(hwndDlg, FREQUENCY_CONFIG, anUnsignedValue);
            WinEnableControl(hwndDlg, DURATION_CONFIG, anUnsignedValue);
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      /* Check Box SURE_CONFIG Event Handlers */
      case SURE_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1009.0  */
            /* Event Clicked/Selected - Are You Sure Prompts SURE_CONFIG */
            c_aus = 1;
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      /* Check Box MINI_CONFIG Event Handlers */
      case MINI_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1010.0  */
            /* Event Clicked/Selected - Mini ICON when shrunk MINI_CONFIG */
            CHAR aTextValue[255]="text";
            LONG anIntegerValue=0;
            ULONG anUnsignedValue=0;

            c_mini = 1;
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      } /* end switch */
      break;

 /* ##START Form.38 User defined messages */
 /* ##END User defined messages */
   default :
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
     return WinDefDlgProc(hwndDlg,msg,mp1,mp2);
   } /* end switch for main msg dispatch */
   return (MRESULT)FALSE;
} /* end dialog procedure */
Example #10
0
void LoadPluginsFunc(void *pParm)
{
  char achFileNamePath[CCHMAXPATHCOMP+10];
  HAB hab;
  HMQ hmq;
  HWND hwndDlg = (HWND) pParm;
  HWND hwndAboutPlugins;
  HWND hwndConfigurePlugins;
  HDIR hdirFindHandle;
  FILEFINDBUF3 FindBuffer;
  ULONG ulResultBufLen;
  ULONG ulFindCount;
  APIRET rc;
  WaWEPlugin_p NewPlugin;
  MENUITEM MenuItem;
  int iPluginCount;

  // Setup this thread for using PM (sending messages etc...)
  hab = WinInitialize(0);
  hmq = WinCreateMsgQueue(hab, 0);

#ifdef DEBUG_BUILD
  printf("Loading plugins...\n");
#endif
  WinSetDlgItemText(hwndDlg, ST_PLUGININFO, "Loading plugins...");

  if (DosRequestMutexSem(PluginListProtector_Sem, SEM_INDEFINITE_WAIT)==NO_ERROR)
  {
    hdirFindHandle = HDIR_CREATE;
    ulResultBufLen = sizeof(FindBuffer);
    ulFindCount = 1;

    chdir("Plugins");

    rc = DosFindFirst( "*.DLL",  // File pattern
                       &hdirFindHandle,  // Search handle
                       FILE_NORMAL,      // Search attribute
                       &FindBuffer,      // Result buffer
                       ulResultBufLen,   // Result buffer length
                       &ulFindCount,     // Number of entries to find
                       FIL_STANDARD);    // Return level 1 file info

    if (rc == NO_ERROR)
    {
      do {
        sprintf(achFileNamePath, "%s", FindBuffer.achName);
#ifdef DEBUG_BUILD
        printf("  Check DLL [%s] : ", achFileNamePath); fflush(stdout);
#endif
        WinSetDlgItemText(hwndDlg, ST_PLUGININFO, achFileNamePath);

        NewPlugin = CreatePluginListElement(hwndDlg, achFileNamePath);
        if (NewPlugin)
        {
          NewPlugin->pNext = PluginListHead;
          if (PluginListHead)
            PluginListHead->pPrev = NewPlugin;
          PluginListHead = NewPlugin;
#ifdef DEBUG_BUILD
          printf("Found Plugin: %s\n", NewPlugin->achName); fflush(stdout);
#endif
        }
#ifdef DEBUG_BUILD
        else
          printf("Not a Plugin\n"); fflush(stdout);
#endif


        ulFindCount = 1; // Reset find count

        rc = DosFindNext( hdirFindHandle,  // Find handle
                          &FindBuffer,     // Result buffer
                          ulResultBufLen,  // Result buffer length
                          &ulFindCount);   // Number of entries to find
      } while (rc == NO_ERROR);

      // Close directory search handle
      rc = DosFindClose(hdirFindHandle);
    }
    chdir("..");
    DosReleaseMutexSem(PluginListProtector_Sem);
  }

#ifdef DEBUG_BUILD
  printf("Plugins loaded!\nConfiguring menu items...\n");
#endif

  // Ok, plugins loaded. Now set up the 'About' and 'Configure' menu items
  // of the main window!
  WinSetDlgItemText(hwndDlg, ST_PLUGININFO, "Configuring menu items...");

  if (DosRequestMutexSem(PluginListProtector_Sem, SEM_INDEFINITE_WAIT)==NO_ERROR)
  {
    // Get hwnd of About->Plugins submenu!
    if (WinSendMsg(WinWindowFromID(hwndFrame, FID_MENU),
                   MM_QUERYITEM,
                   MPFROM2SHORT(IDM_ABOUTPLUGINS, TRUE),
                   (MPARAM) (&MenuItem)))
    {
      hwndAboutPlugins = MenuItem.hwndSubMenu;
    } else
      hwndAboutPlugins = NULL;

    // Get hwnd of Configure->Plugins submenu!
    if (WinSendMsg(WinWindowFromID(hwndFrame, FID_MENU),
                   MM_QUERYITEM,
                   MPFROM2SHORT(IDM_CONFIGUREPLUGINS, TRUE),
                   (MPARAM) (&MenuItem)))
    {
      hwndConfigurePlugins = MenuItem.hwndSubMenu;
    } else
      hwndConfigurePlugins = NULL;

    NewPlugin = PluginListHead;
    iPluginCount = 0;
    while (NewPlugin)
    {
      // Add to About->Plugins, if has About function
      if (NewPlugin->fnAboutPlugin)
      {
#ifdef DEBUG_BUILD
        printf("  Adding to About->Plugins: %s\n", NewPlugin->achName);
#endif
        MenuItem.iPosition = 0;
        MenuItem.afStyle = MIS_TEXT;
        MenuItem.afAttribute = 0;
        MenuItem.id = iPluginCount + ABOUTMENU_ID_BASE;
        MenuItem.hwndSubMenu = NULL;
        MenuItem.hItem = 0;
        WinSendMsg(hwndAboutPlugins,
                   MM_INSERTITEM,
                   (MPARAM) &MenuItem,
                   (MPARAM) (NewPlugin->achName));
      }
      // Add to Configure->Plugins, if has Configure function
      if (NewPlugin->fnConfigurePlugin)
      {
#ifdef DEBUG_BUILD
        printf("  Adding to Configure->Plugins: %s\n", NewPlugin->achName);
#endif
        MenuItem.iPosition = 0;
        MenuItem.afStyle = MIS_TEXT;
        MenuItem.afAttribute = 0;
        MenuItem.id = iPluginCount + CONFIGUREMENU_ID_BASE;
        MenuItem.hwndSubMenu = NULL;
        MenuItem.hItem = 0;
        WinSendMsg(hwndConfigurePlugins,
                   MM_INSERTITEM,
                   (MPARAM) &MenuItem,
                   (MPARAM) (NewPlugin->achName));
      }
      NewPlugin = NewPlugin->pNext; iPluginCount++;
    }
    DosReleaseMutexSem(PluginListProtector_Sem);
  }
#ifdef DEBUG_BUILD
  printf("Menu items configured!\n");
#endif


  WinPostMsg(hwndDlg, WM_CLOSE, 0, 0);

  WinDestroyMsgQueue(hmq);
  WinTerminate(hab);

#ifdef DEBUG_BUILD
  /*
  printf("The following plugins have been loaded:\n");
  if (DosRequestMutexSem(PluginListProtector_Sem, SEM_INDEFINITE_WAIT)==NO_ERROR)
  {
    NewPlugin = PluginListHead;
    while (NewPlugin)
    {
      printf("  [%s] (type %d, importance %d)", NewPlugin->achName, NewPlugin->iPluginType, NewPlugin->iPluginImportance);
      if (NewPlugin->iPluginType == WAWE_PLUGIN_TYPE_IMPORT)
      {
        printf("  fnOpen() = 0x%p\n", NewPlugin->TypeSpecificInfo.ImportPluginInfo.fnOpen);
      } else
      {
        printf("\n");
      }
      NewPlugin = NewPlugin->pNext;
    }
    DosReleaseMutexSem(PluginListProtector_Sem);
  }
  */
#endif


  _endthread();
}
Example #11
0
/*------------------------------------------------------------------------*/
MRESULT EXPENTRY GridSizeDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
   static WINDOWINFO *pwi;
   ULONG  ulStorage[2];    /* To get the vals out of the spins  */
   PVOID  pStorage;        /* idem spinbutton.                  */

   SWP   swp;

   switch(msg)
   {
      case WM_INITDLG:
         pwi  = (WINDOWINFO *)mp2;
         /* Centre dialog on the screen        */

         WinQueryWindowPos(hwnd, (PSWP)&swp);
         WinSetWindowPos(hwnd, HWND_TOP,
                       ((WinQuerySysValue(HWND_DESKTOP,        SV_CXSCREEN) - swp.cx) / 2),
                       ((WinQuerySysValue(HWND_DESKTOP,        SV_CYSCREEN) - swp.cy) / 2),
                       0, 0, SWP_MOVE);

         /*
         ** Display interval spinbutton.
         */
         if (pwi->paper == IDM_MM)
         {
            /*
            ** 0.1 mm precision.
            */
            WinSendDlgItemMsg( hwnd, ID_GRIDSPIN, SPBM_SETLIMITS,
                               MPFROMLONG(MAXGRIDDISP),MPFROMLONG(MINGRIDDISP));

            WinSendDlgItemMsg( hwnd, ID_GRIDSPIN, SPBM_SETCURRENTVALUE,
                               MPFROMLONG((LONG)pwi->ulgriddisp), NULL);
            /*
            ** Gridsize in x direction.
            */
            WinSendDlgItemMsg( hwnd, ID_SPINGRIDX, SPBM_SETLIMITS,
                               MPFROMLONG(MAXGRIDSIZE),MPFROMLONG(MINGRIDSIZE));

            WinSendDlgItemMsg( hwnd, ID_SPINGRIDX,SPBM_SETCURRENTVALUE,
                               MPFROMLONG((LONG)pwi->ulgridcx), NULL);
            /*
            ** Gridsize in y direction.
            */
            WinSendDlgItemMsg( hwnd, ID_SPINGRIDY, SPBM_SETLIMITS,
                               MPFROMLONG(MAXGRIDSIZE),MPFROMLONG(MINGRIDSIZE));

            WinSendDlgItemMsg( hwnd, ID_SPINGRIDY,SPBM_SETCURRENTVALUE,
                               MPFROMLONG((LONG)pwi->ulgridcy), NULL);

         }
         else
         {
            LONG Inch;
            /*
            ** 0.1 inch precision.
            */
            WinSetDlgItemText (hwnd,ID_GRPGRID,"Value's * 0.1 Inch");

            WinSendDlgItemMsg( hwnd, ID_GRIDSPIN, SPBM_SETLIMITS,MPFROMLONG(MAXGRIDDISP),
                               MPFROMLONG(MINGRIDDISP));

            Inch = pwi->ulgriddisp / 2.54;

            WinSendDlgItemMsg( hwnd, ID_GRIDSPIN, SPBM_SETCURRENTVALUE,
                               MPFROMLONG((LONG)Inch), NULL);
            /*
            ** Gridsize in x direction.
            */
            WinSendDlgItemMsg( hwnd, ID_SPINGRIDX, SPBM_SETLIMITS,
                               MPFROMLONG(MAXINCHGRIDSIZE),
                               MPFROMLONG(MININCHGRIDSIZE));

            Inch = pwi->ulgridcx / 2.54;
            WinSendDlgItemMsg( hwnd, ID_SPINGRIDX,SPBM_SETCURRENTVALUE,
                               MPFROMLONG((LONG)Inch), NULL);
            /*
            ** Gridsize in y direction.
            */
            WinSendDlgItemMsg( hwnd, ID_SPINGRIDY, SPBM_SETLIMITS,
                               MPFROMLONG(MAXINCHGRIDSIZE),
                               MPFROMLONG(MININCHGRIDSIZE));

            Inch = pwi->ulgridcy / 2.54;

            WinSendDlgItemMsg( hwnd, ID_SPINGRIDY,SPBM_SETCURRENTVALUE,
                               MPFROMLONG((LONG)Inch), NULL);
         }
         return (MRESULT)0;

      case WM_COMMAND:
         switch(LOUSHORT(mp1))
         {
            case DID_OK:
               pStorage = (PVOID)ulStorage;
               /* display interval */

               WinSendDlgItemMsg(hwnd,ID_GRIDSPIN,SPBM_QUERYVALUE,
                                 (MPARAM)(pStorage),MPFROM2SHORT(0,0));
               if (ulStorage[0] >= MINGRIDDISP && ulStorage[0] <= MAXGRIDDISP )
               {
                  if (pwi->paper == IDM_MM)
                     pwi->ulgriddisp = ulStorage[0];
                  else
                     pwi->ulgriddisp = ulStorage[0] * 2.54; /*back to 0.1 mm */
               }
               /* x - direction */
               WinSendDlgItemMsg(hwnd,ID_SPINGRIDX,SPBM_QUERYVALUE,
                                 (MPARAM)(pStorage),MPFROM2SHORT(0,0));
               if (ulStorage[0] >= MINGRIDSIZE && ulStorage[0] <= MAXGRIDSIZE )
               {
                  if (pwi->paper == IDM_MM)
                     pwi->ulgridcx = ulStorage[0];
                  else
                     pwi->ulgridcx = ulStorage[0] * 2.54;
               }
               /* y - direction */
               WinSendDlgItemMsg(hwnd,ID_SPINGRIDY,SPBM_QUERYVALUE,
                                 (MPARAM)(pStorage),MPFROM2SHORT(0,0));
               if (ulStorage[0] >= MINGRIDSIZE && ulStorage[0] <= MAXGRIDSIZE )
               {
                  if (pwi->paper == IDM_MM)
                     pwi->ulgridcy = ulStorage[0];
                  else
                     pwi->ulgridcy = ulStorage[0] * 2.54;
               }
               WinPostMsg(pwi->hwndClient,UM_ENDDIALOG,(MPARAM)0,(MPARAM)0);               WinDismissDlg(hwnd,DID_OK);
               break;
            case DID_CANCEL:
               WinDismissDlg(hwnd,DID_CANCEL);
               break;
         }
         return (MRESULT)0;
   }
   return(WinDefDlgProc(hwnd, msg, mp1, mp2));
}
void        MsdThumbnailThread( void * camthumbptr)

{
    uint32_t        rc = 0;
    uint32_t        errCtr = 0;
    char *          pBuf = 0;
    CAMThumbPtr     pct = (CAMThumbPtr)camthumbptr;
    CAMRecPtr *     ppcr = pct->pcr;
    CAMRecPtr       pcr;

do{
    rc = DosRequestMutexSem( pct->thisCam->hmtxCam, CAM_MUTEXWAIT);
    if (rc)
        break;

    while (*ppcr) {
        pcr = *ppcr;
        ppcr++;

        if (!pcr->tnsize)
            continue;

        // get the thumb from the file
        rc = MsdGetThumb( pcr, &pBuf);
        if (rc) {
            if (++errCtr > 2)
                break;
            continue;
        }

        errCtr = 0;

        // if rotate-on-load is set, set the
        // Exif orientation info from the main image
        if (pct->fRotate && pcr->rot)
            SetOrientation( pcr->rot, pcr);

        // create the bitmap
        pcr->bmp = CreateThumbnailBmp( pcr, pBuf);

        // free the memory allocated by GetThumb()
        free( pBuf);
        pBuf = 0;

        // let the main thread know we finished processing this record
        if (pcr->bmp &&
            !WinPostMsg( pct->hReply, CAMMSG_FETCHTHUMBS, (MP)pcr, 0))
            printf( "MsdThumbnailThread - WinPostMsg failed\n");
    }

    DosReleaseMutexSem( pct->thisCam->hmtxCam);

} while (0);

    WinPostMsg( pct->hReply, CAMMSG_FETCHTHUMBS, (MP)-1, (MP)rc);

    if (pBuf)
        free( pBuf);

    free( pct);

    return;
}
void        PtpThumbnailThread( void * camthumbptr)

{
    uint32_t        rc = 0;
    uint32_t        errCtr = 0;
    char *          pBuf = 0;
    CAMThumbPtr     pct = (CAMThumbPtr)camthumbptr;
    CAMRecPtr *     ppcr = pct->pcr;
    CAMRecPtr       pcr;

do{
    rc = DosRequestMutexSem( pct->thisCam->hmtxCam, CAM_MUTEXWAIT);
    if (rc)
        break;

    while (*ppcr) {
        pcr = *ppcr;

        // get the thumb from the camera
        rc = GetThumb( pct->thisCam->hCam, pcr->hndl, &pBuf);
        if (rc) {
            printf( "PtpThumbnailThread - GetThumb #1 - handle= %d  rc= 0x%x\n",
                    (int)pcr->hndl, (int)rc);
            if (rc == CAMERR_NULLCAMERAPTR)
                break;

            rc = ClearStall( pct->thisCam->hCam);
            if (rc == CAMERR_NULLCAMERAPTR)
                break;

            rc = GetThumb( pct->thisCam->hCam, pcr->hndl, &pBuf);
            if (rc) {
                printf( "PtpThumbnailThread - GetThumb #2 - handle= %d  rc= 0x%x\n",
                        (int)pcr->hndl, (int)rc);
                if (rc == CAMERR_NULLCAMERAPTR)
                    break;

                ClearStall( pct->thisCam->hCam);
                if (++errCtr > 2)
                    break;
            }
        }

        if (!rc) {
            errCtr = 0;

            // if rotate-on-load is set, get the
            // Exif orientation info from the main image
            if (pct->fRotate &&
                pcr->fmtnbr == PTP_OFC_EXIF_JPEG &&
                pcr->size >= 500)
                    PtpGetOrientation( pct->thisCam, pcr);

            // create the bitmap
            pcr->bmp = CreateThumbnailBmp( pcr, pBuf);
        }

        // free the memory allocated by GetThumb()
        if (pBuf) {
            free( pBuf);
            pBuf = 0;
        }

        // let the main thread know we finished processing this record
        if (pcr->bmp &&
            !WinPostMsg( pct->hReply, CAMMSG_FETCHTHUMBS, (MP)pcr, 0))
            printf( "PtpThumbnailThread - WinPostMsg failed\n");

        ppcr++;
    }

    DosReleaseMutexSem( pct->thisCam->hmtxCam);

} while (0);

    WinPostMsg( pct->hReply, CAMMSG_FETCHTHUMBS, (MP)-1, (MP)rc);

    free( pct);

    return;
}
Example #14
0
/*----------------------------------------------------------------------*/
MRESULT EXPENTRY DMLBSubclassListboxProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
/*----------------------------------------------------------------------*/
/* This window procedure is used to subclass a standard PM listbox      */
/* control.  This procedure will intercept certain mouse events on the  */
/* listbox to implement direct-manipulation functions.                  */
/*----------------------------------------------------------------------*/
{
SHORT    Item;          /* Listbox item number                          */
DMLBData  *InstData;     /* This instance-specific data (per listbox)    */

   /* The lisbox window pointer is to our instance data. */

   InstData = WinQueryWindowPtr(hwnd, QWL_USER);
     
   switch (msg) {
      /* Since this is just a subclass setup after the listbox window */
      /* is created, we never get a WM_CREATE message here.           */

      case WM_DESTROY:
           /* The listbox window is being destroyed.  Cleanup any     */
           /* resources we have allocated in this subclass.           */
           if (InstData->DragMIcon != NULLHANDLE) {
             WinDestroyPointer(InstData->DragMIcon);
             WinDestroyPointer(InstData->DragCIcon);
             WinDestroyPointer(InstData->NorthIcon);
             WinDestroyPointer(InstData->SouthIcon);
             WinDestroyPointer(InstData->DragNoDrp);
             WinDestroyPointer(InstData->DeletIcon);
             InstData->DragMIcon = NULLHANDLE;
           }
           /* Cleanup other resources */
           if (InstData->Dragging) {
             WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID);
           }
           /* Release instance data */
           free(InstData);
           WinSetWindowPtr(hwnd, 0L, NULL);
           break;

      case WM_TIMER:
           /* We get timer messages during dragging to implement */
           /* auto-scrolling of listbox when pointer is placed   */
           /* north or south of the listbox while dragging.      */

           if (!InstData->Dragging)  /* Ignore if not dragging   */
             break;

           if (SHORT1FROMMP(mp1)==DRAG_TIMERID) {
             switch (InstData->PrevLocation) { // Last known location of the pointer
               case POINT_INSIDE:
               case POINT_OUTSIDE:
                 /* Do nothing */
                 break;

               case POINT_NORTH:
                 /* Scroll up one item */
                 Item = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYTOPINDEX,  0L, 0L);
                 if ((Item != LIT_NONE) && (Item != 0))
                    WinPostMsg(InstData->TargetHwnd, LM_SETTOPINDEX, MPFROMSHORT(Item-1), 0L);
                 break;

               case POINT_SOUTH:
                 /* Scroll down one item */
                 Item = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYTOPINDEX,  0L, 0L);
                 if (Item != LIT_NONE)
                    WinPostMsg(InstData->TargetHwnd, LM_SETTOPINDEX, MPFROMSHORT(Item+1), 0L);
                 break;
             } /* switch on PrevLocation */
             return 0;
           }
           break;

      case WM_CONTEXTMENU: {
           SHORT CursorIndx, Max;

           /* User requested context menu... notify our owner.          */

           /* First find out what item the pointer is over.             */
           Max = (SHORT)WinSendMsg( hwnd, LM_QUERYITEMCOUNT, 0L, 0L );
           CursorIndx = DMLBLocateListboxItem(hwnd, hwnd, SHORT2FROMMP(mp1), LLI_UNDER);
           if ((Max == 0) || (CursorIndx+1 > Max))
             CursorIndx = LIT_NONE;

           /* Tell our owner about it */
           return WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL,
                      MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_CONTEXT),
                      MPFROMSHORT(CursorIndx));
           }
 
      case WM_MOUSEMOVE:
           /* Monitor the position of the mouse relative to the listbox */
           /* so we can set the pointer icon correctly and note the     */
           /* position for use during WM_TIMER processing.              */

           if (!InstData->Dragging)   /* Ignore if not dragging */
             break;

           DMLBCheckTargetLocation(hwnd, InstData, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));

           /* Set pointer icon appropriate for location */
           if (InstData->DragMIcon == NULLHANDLE) {
             // Load all the pointers (one time only)
             InstData->DragMIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGMOVE);
             InstData->DragCIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGCOPY);
             InstData->DragNoDrp= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGNONE);
             InstData->NorthIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGNORTH);
             InstData->SouthIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGSOUTH);
             InstData->DeletIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGDEL);
           }
           switch (InstData->PrevLocation) {
             case POINT_INSIDE:
               switch (InstData->TargetDropMode) {
               case DROPMODE_MOVE:
                 WinSetPointer(HWND_DESKTOP, InstData->DragMIcon); // Use MOVE pointer 
                 break;
               case DROPMODE_COPY:
                 WinSetPointer(HWND_DESKTOP, InstData->DragCIcon); // Use COPY pointer
                 break;
               case DROPMODE_DELETE:
                 WinSetPointer(HWND_DESKTOP, InstData->DeletIcon); // Use DELETE pointer
                 break;
               }
               break;
             case POINT_OUTSIDE:
               WinSetPointer(HWND_DESKTOP, InstData->DragNoDrp);   // No-drop pointer
               break;
             case POINT_NORTH:
               WinSetPointer(HWND_DESKTOP, InstData->NorthIcon);   // Scroll-up pointer
               break;
             case POINT_SOUTH:
               WinSetPointer(HWND_DESKTOP, InstData->SouthIcon);   // Scroll-down poineter
               break;
           }
 
           return (MRESULT)TRUE;  /* Note we processed the message */

      case WM_BEGINDRAG:
           {
           SHORT  Max;
           SHORT i, CursorIndx, hit;

           /* User started dragging with the pointer on our window */

           Max = (SHORT)WinSendMsg( hwnd, LM_QUERYITEMCOUNT, 0L, 0L );

           /* If we are currently dragging, cancel it (should not happen) */
 
           if ( InstData->Dragging ) {
             InstData->Dragging = FALSE;
             WinSetCapture( HWND_DESKTOP, NULLHANDLE );
             return (MRESULT)FALSE;
           }

           /* Get index of item under the mouse pointer and check */
           /* for reasonable numeric bounds.                      */
 
           CursorIndx = DMLBLocateListboxItem(hwnd, hwnd, SHORT2FROMMP(mp1), LLI_UNDER);
           if ((Max == 0) || (CursorIndx+1 > Max)) {
             DosBeep( 440L, 50L );  // Don't allow drag if not on a listbox item
             return (MRESULT)FALSE;
           }

           /* Since we currently support dragging only a single item, */
           /* de-select all items and just select the one under the   */
           /* pointer.  To support multiple-drag we would probably    */
           /* need to notify the owner so they could set the selection*/
           /* status of all items to be dragged (which may or may not */
           /* include the item under the pointer).                    */

           WinSendMsg(hwnd, LM_SELECTITEM, MPFROMSHORT(LIT_NONE), MPVOID);
           WinSendMsg(hwnd, LM_SELECTITEM, MPFROMSHORT(CursorIndx), MPFROMSHORT(TRUE));

           /* Note we are now dragging and capture the pointer. */
 
           InstData->Dragging = TRUE;
           WinSetCapture( HWND_DESKTOP, hwnd );
           InstData->PrevLocation = POINT_INSIDE;
           WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID, WinQuerySysValue(HWND_DESKTOP, SV_SCROLLRATE));
           return (MRESULT)TRUE;
           break;
           }
 
      case WM_ENDDRAG:
            {
            SHORT DropIndx, CurrIndx;
            SHORT SourceMax, TargetMax;      /* Num of items in source/target listbox */
            char  *CopyText;                 /* Text to be copied/moved */
            USHORT CopyTextLen;              /* Length of text */
            void   *CopyHand;                /* Handle of item to be copied/moved */
            BOOL  SameList = FALSE;          /* Source and target are same listbox */
 
            if (!InstData->Dragging)         /* Ignore if we are not dragging */
              return (MRESULT)FALSE;
 
            /* Clear dragging indicators and release pointer */

            InstData->Dragging = FALSE;
            WinSetCapture( HWND_DESKTOP, NULLHANDLE );
            WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID);

            /* See if what is under the pointer will accept the drop */
            DMLBCheckTargetLocation(hwnd, InstData, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));
            if (InstData->PrevLocation != POINT_INSIDE)
              return (MRESULT)TRUE;  /* Ignore drop outside a good listbox */

            if (hwnd == InstData->TargetHwnd)  // Source and target are same listbox
              SameList = TRUE;

            SourceMax = (SHORT)WinSendMsg(hwnd, LM_QUERYITEMCOUNT, 0L, 0L ) -1;
            TargetMax = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYITEMCOUNT, 0L, 0L ) -1;

            /* Get drop point and original selected point */

            DropIndx = DMLBLocateListboxItem(InstData->TargetHwnd, hwnd, SHORT2FROMMP(mp1), LLI_INSERTPOINT);
            CurrIndx = (SHORT)WinSendMsg(hwnd, LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), 0L);

            /* Prevent move onto same item as source, in same listbox           */
            /* being careful of DropIndx > SourceMax when drop after last item. */
            if ((InstData->TargetDropMode==DROPMODE_MOVE) &&
                (SameList) &&
                ((min(DropIndx,SourceMax) == CurrIndx) || (DropIndx == CurrIndx+1))) {
              DosBeep( 700L, 50L );  /* Don't drop before or after original */
              return (MRESULT)TRUE;
            }

            /* Make a copy of original to insert */

            CopyTextLen = (SHORT)WinSendMsg(hwnd,LM_QUERYITEMTEXTLENGTH,MPFROMSHORT(CurrIndx), 0L) + 1;
            CopyText = malloc(CopyTextLen);
            WinSendMsg(hwnd, LM_QUERYITEMTEXT, MPFROM2SHORT(CurrIndx, CopyTextLen), MPFROMP(CopyText));
            CopyHand = WinSendMsg(hwnd, LM_QUERYITEMHANDLE, MPFROMSHORT(CurrIndx), 0L);

            /* Insert before insertion point, or at end of list */
            if (DropIndx > TargetMax)
              DropIndx = LIT_END;

            /* Disable update during insert/delete for smoother visual and */
            /* prevent ownerdraw from occuring before new handles are set. */

            WinEnableWindowUpdate(hwnd, FALSE);
            WinEnableWindowUpdate(InstData->TargetHwnd, FALSE);
            
            /* Insert into target list */
            if (InstData->TargetDropMode != DROPMODE_DELETE) {
              DropIndx = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_INSERTITEM, MPFROMSHORT(DropIndx), MPFROMP(CopyText));
              WinSendMsg(InstData->TargetHwnd, LM_SETITEMHANDLE, MPFROMSHORT(DropIndx), MPFROMP(CopyHand));
            }
            free(CopyText);

            /* Tell owner of originating listbox what we are doing.  We must notify */
            /* the owner before we delete items because they may keep dynamic data  */
            /* in the item handles that has to be freed.  The item in question is   */
            /* the currently selected item in the listbox.                          */

            switch (InstData->TargetDropMode) {
              case DROPMODE_MOVE:
                 if (!SameList)
                   WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL,
                           MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_DELETE_MOVE),
                           MPFROMHWND(InstData->TargetHwnd));
                 break;
              case DROPMODE_DELETE:
                 WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL,
                           MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_DELETE),
                           MPFROMHWND(InstData->TargetHwnd));
                 break;
            }

            /* If this is a move, delete original.  If it is in the same  */
            /* listbox as target, get new index since it may have         */
            /* changed due to inserted copy.                              */

            if ((InstData->TargetDropMode == DROPMODE_MOVE) || (InstData->TargetDropMode == DROPMODE_DELETE)) {
              CurrIndx = (SHORT)WinSendMsg(hwnd, LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), 0L);
              WinSendMsg(hwnd, LM_DELETEITEM, MPFROMSHORT(CurrIndx), 0L);
            }

            /* Select the newly inserted item.  If the old copy was             */
            /* above it in the same list, then the item number has changed by 1 */

            if ((DropIndx > CurrIndx) && (SameList) && (InstData->TargetDropMode==DROPMODE_MOVE))
              DropIndx--;
            if (InstData->TargetDropMode != DROPMODE_DELETE) {
              WinSendMsg(InstData->TargetHwnd, LM_SELECTITEM, MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE));
              WinSendMsg(InstData->TargetHwnd, LM_SELECTITEM, MPFROMSHORT(DropIndx), MPFROMSHORT(TRUE));
            }

            WinEnableWindowUpdate(hwnd, TRUE);
            WinEnableWindowUpdate(InstData->TargetHwnd, TRUE);

            /* Notify target of inserted items if necessary */

            switch (InstData->TargetDropMode) {
              case DROPMODE_MOVE:
                if (SameList)
                   WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL,
                         MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_REORDERED),
                         MPFROMHWND(hwnd));
                else
                   WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL,
                         MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_INSERT_MOVE),
                         MPFROMHWND(hwnd));
                break;
              case DROPMODE_COPY:
                WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL,
                         MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_INSERT_COPY),
                         MPFROMHWND(hwnd));
                break;
            }

            return (MRESULT)TRUE;
            }
 
      }
 
   /* Call previous window procedure to process this message */
   return ( (*(InstData->OldProcAddr)) ( hwnd, msg, mp1, mp2 )  );
   }
Example #15
0
static MRESULT EXPENTRY MyWindowProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
{
    HPS    hps;
    RECTL  rc;

    switch( msg ) {

    case WM_CREATE:
        break;

    case WM_COMMAND:
        switch( SHORT1FROMMP( mp1 ) ) {
        case ID_UNLOCK:
            Say( "Unlocked" );
            UnLockIt();
            if( FocusWnd != NULL ) {
                WinSetFocus( HWND_DESKTOP, FocusWnd );
            }
            WinSetActiveWindow( HWND_DESKTOP, hwndClient );
            if( ActiveWnd != NULL ) {
                WinSetActiveWindow( HWND_DESKTOP, ActiveWnd );
            }
            break;
        case ID_SWITCH:
            Say( "Switched" );
            SwitchBack();
            break;
        case ID_EXITPROG:
            WinPostMsg( hwnd, WM_CLOSE, (MPARAM)0, (MPARAM)0 );
            break;
        default:
            return( WinDefWindowProc( hwnd, msg, mp1, mp2 ) );
        }
        break;

    case WM_ERASEBACKGROUND:
        return( (MRESULT)TRUE );

    case WM_PAINT:
        hps = WinBeginPaint( hwnd, 0L, &rc );
#ifdef DEBUG
        {
            POINTL pt;


            pt.x = 0; pt.y = 50;
            GpiSetColor( hps, CLR_NEUTRAL );
            GpiSetBackColor( hps, CLR_BACKGROUND );
            GpiSetBackMix( hps, BM_OVERPAINT );
            GpiCharStringAt( hps, &pt, (LONG)strlen( Message ), Message );
        }
#endif
        WinEndPaint( hps );
        break;

    case WM_CLOSE:
        WinPostMsg( hwnd, WM_QUIT, 0, 0 );
        break;

    case WM_DESTROY:
        UnLockIt();
        // fall thru

    default:
        return( WinDefWindowProc( hwnd, msg, mp1, mp2 ) );

    }
    return( FALSE );
}
MRESULT EXPENTRY CDToolsDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  HAB hab;
  char chrLoadError[CCHMAXPATH];
  STARTDATA startData={0};
  PSZ pszTitle="CDRecord/2";
  APIRET rc;
  PID pid;
  ULONG ulSessionID=0;
  char chrParams[CCHMAXPATH];
  char chrParams2[20];
  
  switch( msg )
    {
    case WM_INITDLG:
      {
	WinCheckButton(hwnd,RBID_FAST,TRUE);
	WinCheckButton(hwnd,RBID_LOADDISK,TRUE);
	WinCheckButton(hwnd,CBID_DUMMY,TRUE);
	WinCheckButton(hwnd,CBID_FIXDUMMY,TRUE);
      }
      return (MRESULT) TRUE;
    case WM_DESTROY:
      
      break;
    case WM_CLOSE:
      if(WinMessageBox(  HWND_DESKTOP,
		       hwnd,
		       "Do you really want to quit?",
		       "Question",
		       0UL,
		       MB_OKCANCEL | MB_ICONQUESTION )==MBID_OK)
	WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
      return 0;
    case WM_COMMAND:
      {
	memset(&startData,0,sizeof(startData));
	startData.Length=sizeof(startData);
	startData.Related=SSF_RELATED_INDEPENDENT;
	startData.FgBg=SSF_FGBG_FORE;
	startData.TraceOpt=SSF_TRACEOPT_NONE;
	startData.PgmTitle=pszTitle;
	startData.PgmName=chrCDRecord;
    /* 13.Apr.2000: changed to SSF_INHERTOPT_PARENT so modified environment by a skript is inherited */ 
	startData.InheritOpt=SSF_INHERTOPT_PARENT;
	startData.SessionType=SSF_TYPE_WINDOWABLEVIO;
	startData.PgmControl=SSF_CONTROL_VISIBLE|SSF_CONTROL_MAXIMIZE|SSF_CONTROL_NOAUTOCLOSE;
	startData.InitXPos=30;
	startData.InitYPos=30;
	startData.InitXSize=500;
	startData.InitYSize=400;
	startData.ObjectBuffer=chrLoadError;
	startData.ObjectBuffLen=(ULONG)sizeof(chrLoadError);
	switch( SHORT1FROMMP( mp1 ) )
	  {
	  case PBID_BLANK:
	    if(!WinQueryButtonCheckstate(hwnd,CBID_DUMMY)) {
	      if(WinMessageBox(  HWND_DESKTOP,
			       hwnd,
			       "Do you really want to perform a real write?",
			       "Dummy is unchecked!",
			       0UL,
			       MB_OKCANCEL | MB_ICONEXCLAMATION )==MBID_CANCEL)break;
	      sprintf(chrParams2,"%s","");
	    }
	    else
	      sprintf(chrParams2,"%s","-dummy");
	    if(WinQueryButtonCheckstate(hwnd,RBID_FAST))
	      sprintf(chrParams,"%s %s %s",chrCDROptions,chrParams2,"-blank=fast -eject");
	    if(WinQueryButtonCheckstate(hwnd,RBID_ALL))
	      sprintf(chrParams,"%s %s %s",chrCDROptions,chrParams2,"-blank=all -eject");
	    if(WinQueryButtonCheckstate(hwnd,RBID_LASTSESSION))
	      sprintf(chrParams,"%s %s %s",chrCDROptions,chrParams2,"-blank=session -eject");
	    if(WinQueryButtonCheckstate(hwnd,RBID_UNCLOSE))
	      sprintf(chrParams,"%s %s %s",chrCDROptions,chrParams2,"-blank=unclose -eject");
	    startData.PgmInputs=chrParams;
	    rc=DosStartSession(&startData,&ulSessionID,&pid);					
	    break;
	  case PBID_FIX:
	    if(!WinQueryButtonCheckstate(hwnd,CBID_FIXDUMMY)) {
	      if(WinMessageBox(  HWND_DESKTOP,
			       hwnd,
			       "Do you really want to perform a real write?",
			       "Dummy is unchecked!",
			       0UL,
			       MB_OKCANCEL | MB_ICONEXCLAMATION )==MBID_CANCEL)break;
	      sprintf(chrParams,"%s %s",chrCDROptions," -fix");
	    }
	    else
	      sprintf(chrParams,"%s %s",chrCDROptions,"-dummy -fix");			
	    startData.PgmInputs=chrParams;
	    rc=DosStartSession(&startData,&ulSessionID,&pid);
	    break;
	  case PBID_MISC:
	    if(WinQueryButtonCheckstate(hwnd,RBID_UNLOADDISK))
	      sprintf(chrParams,"%s %s",chrCDROptions,"-eject");
	    else if(WinQueryButtonCheckstate(hwnd,RBID_LOADDISK))
	      sprintf(chrParams,"%s %s",chrCDROptions,"-load");
	    else if(WinQueryButtonCheckstate(hwnd,RBID_RESETDEVICE))
	      sprintf(chrParams,"%s %s",chrCDROptions,"-reset");
	    else if(WinQueryButtonCheckstate(hwnd,RBID_SHOWTOC))
	      sprintf(chrParams,"%s %s",chrCDROptions,"-toc");
	    else if(WinQueryButtonCheckstate(hwnd,RBID_SHOWATIP))
	      sprintf(chrParams,"%s %s",chrCDROptions,"-atip");


	    startData.PgmInputs=chrParams;
	    rc=DosStartSession(&startData,&ulSessionID,&pid);
	    break;
	  case PBID_EXIT:
	    WinPostMsg(hwnd,WM_CLOSE,(MPARAM)0,(MPARAM)0);
	    break;
	  case PBID_SETTINGS:
	    if( WinDlgBox( HWND_DESKTOP, hwnd, CDSettingsDlgProc, NULLHANDLE,DLGID_SETUP, 0 ) == DID_ERROR )
	      {
		WinMessageBox(  HWND_DESKTOP,
			      HWND_DESKTOP,
			      "Warning! Cannot open Settings dialog!",
			      "",
			      0UL,
			      MB_OK | MB_ICONEXCLAMATION );
	      }
	    break;
	  default:
	    break;
	  }
      }
      return (MRESULT) TRUE;
      break;
    }	
  return( WinDefDlgProc( hwnd, msg, mp1, mp2 ) );	
}
Example #17
0
BOOL MoveCurrentDesktop(HAB hab,
                        LONG dx,       // in: X delta
                        LONG dy)       // in: Y delta
{
    BOOL    brc = FALSE;

    LONG    cxEach = G_pHookData->szlEachDesktopFaked.cx,
            cDesktopsX = G_pHookData->PagerConfig.cDesktopsX,
            xCurrent = G_pHookData->ptlCurrentDesktop.x,
            xLimit = cDesktopsX * cxEach,
            xNew = xCurrent - dx;

    LONG    cyEach = G_pHookData->szlEachDesktopFaked.cy,
            cDesktopsY = G_pHookData->PagerConfig.cDesktopsY,
            yCurrent = G_pHookData->ptlCurrentDesktop.y,
            yLimit = cDesktopsY * cyEach,
            yNew = yCurrent - dy;

    ULONG   flPager = G_pHookData->PagerConfig.flPager;

    // bump X delta
    if (dx)
    {
        if (xNew < 0)
        {
            if (flPager & PGRFL_WRAPAROUND)
                dx = -((cDesktopsX - 1) * cxEach);
            else
                dx = 0;
        }
        else if ((xNew + cxEach) > xLimit)
        {
            if (flPager & PGRFL_WRAPAROUND)
                dx = (cDesktopsX - 1) * cxEach;
            else
                dx = 0;
        }
    }

    // bump Y delta
    if (dy)
    {
        if (yNew < 0)
        {
            if (flPager & PGRFL_WRAPAROUND)
                dy = -((cDesktopsY - 1) * cyEach);
            else
                dy = 0;
        }
        else if ((yNew + cyEach) > yLimit)
        {
            if (flPager & PGRFL_WRAPAROUND)
                dy = (cDesktopsY - 1) * cyEach;
            else
                dy = 0;
        }
    }

    if (    (dx)
         || (dy)
       )
    {
        BOOL    fAnythingMoved = TRUE;

        PSWP    paswpNew = NULL;
        ULONG   cSwpNewUsed = 0;

        HWND    *pahwndNoMoveWithOwner = NULL;
        ULONG   cNoMoveWithOwner = 0;

        if (pgrLockWinlist())
        {
            // allocate an array of SWP entries for moving all windows
            // at once... we'll allocate one SWP entry for each item
            // on the wininfo list, but we'll probably not use them
            // all. cSwpNewUsed will be incremented for each item that's
            // actually used. While we build that list, we check the
            // internal daemon winlist for sanity, since we sometimes
            // do not pick up all relevant changes such as "parent changed",
            // which will block the WinSetMultWindowPos otherwise.
            ULONG       cWinInfos,
                        cbSwpNew,
                        cbNoMoveWithOwner;

            if (    (cWinInfos = lstCountItems(&G_llWinInfos))
                 && (cbSwpNew = cWinInfos * sizeof(SWP))
                 && (cbNoMoveWithOwner  = cWinInfos * sizeof(HWND))
                 // allocate array of SWPs WinSetMultWindowPos:
                 && (paswpNew = (PSWP)malloc(cbSwpNew))
                 // allocate array of HWNDs for which we
                 // might disable FS_NOMOVEWITHOWNER:
                 && (pahwndNoMoveWithOwner  = (HWND*)malloc(cbNoMoveWithOwner))
               )
            {
                PLISTNODE    pNode, pNext;

                // now go thru all windows on the main list and copy them
                // to the move list, if necessary
                for (pNode = lstQueryFirstNode(&G_llWinInfos); pNode; pNode = pNext)
                {
                    PXWININFO pEntryThis = (PXWININFO)pNode->pItemData;

                    pNext = pNode->pNext;
                    if (    (!WinQueryWindowPos(pEntryThis->data.swctl.hwnd,
                                                &pEntryThis->data.swp))
                            // check if it's still a desktop child (fixes #524)
                         || (WinQueryWindow(pEntryThis->data.swctl.hwnd,QW_PARENT) != G_pHookData->hwndPMDesktop)
                       )
                        // window no longer valid:
                        // remove from the list NOW
                        WinPostMsg(G_pHookData->hwndDaemonObject,
                                   XDM_WINDOWCHANGE,
                                   (MPARAM)pEntryThis->data.swctl.hwnd,
                                   (MPARAM)WM_DESTROY);
                    else
                    {
                        BOOL fRefreshThis = FALSE;

                        // fix outdated minimize/maximize/hide flags
                        if (    (pEntryThis->data.bWindowType == WINDOW_MINIMIZE)
                             && (!(pEntryThis->data.swp.fl & SWP_MINIMIZE))
                           )
                            // no longer minimized:
                            fRefreshThis = TRUE;
                        else if (    (pEntryThis->data.bWindowType == WINDOW_MAXIMIZE)
                                  && (!(pEntryThis->data.swp.fl & SWP_MAXIMIZE))
                                )
                            // no longer minimized:
                            fRefreshThis = TRUE;

                        if (pEntryThis->data.bWindowType == WINDOW_NORMAL)
                        {
                            if (pEntryThis->data.swp.fl & SWP_HIDE)
                                fRefreshThis = TRUE;
                            else if (pEntryThis->data.swp.fl & SWP_MINIMIZE)
                                // now minimized:
                                pEntryThis->data.bWindowType = WINDOW_MINIMIZE;
                            else if (pEntryThis->data.swp.fl & SWP_MAXIMIZE)
                                // now maximized:
                                pEntryThis->data.bWindowType = WINDOW_MAXIMIZE;
                        }

                        if (fRefreshThis)
                        {
                            if (!pgrGetWinData(&pEntryThis->data,
                                               TRUE))       // quick check, we already have most data
                            {
                                // window no longer valid:
                                // remove from the list NOW
                                // V0.9.15 (2001-09-14) [umoeller]
                                WinPostMsg(G_pHookData->hwndDaemonObject,
                                           XDM_WINDOWCHANGE,
                                           (MPARAM)pEntryThis->data.swctl.hwnd,
                                           (MPARAM)WM_DESTROY);

                                // update pEntryThis so that we don't try to
                                // move it later
                                // V0.9.19 (2002-04-04) [lafaix]
                                pEntryThis = NULL;
                            }
                        }

                        // move the window if it is not sticky, minimized,
                        // hidden, or invisible
                        // V0.9.19 (2002-04-04) [lafaix]
                        if (    (pEntryThis)
                             && (    (pEntryThis->data.bWindowType == WINDOW_MAXIMIZE)
                                  || (    (pEntryThis->data.bWindowType == WINDOW_NORMAL)
                                       && (!(pEntryThis->data.swp.fl & SWP_HIDE))
                                     )
                                  || (    (pEntryThis->data.bWindowType == WINDOW_NIL)
                                       && (!(pEntryThis->data.swp.fl & SWP_HIDE))
                                       && (WinQueryWindowULong(pEntryThis->data.swctl.hwnd,
                                                               QWL_STYLE)
                                                   & WS_VISIBLE)
                                     )
                                )
                           )
                        {
                            // OK, window to be moved:

                            // default flags
                            ULONG   fl = SWP_MOVE | SWP_NOADJUST;
                                    // SWP_NOADJUST is required or the windows
                                    // will end up in the middle of nowhere

                            PSWP    pswpNewThis = &paswpNew[cSwpNewUsed];

                            // we have queried the window pos above
                            memcpy(pswpNewThis,
                                   &pEntryThis->data.swp,
                                   sizeof(SWP));

                            pswpNewThis->hwnd = pEntryThis->data.swctl.hwnd;
                            // add the delta for moving
                            pswpNewThis->x += dx;
                            pswpNewThis->y += dy;

                            pswpNewThis->fl = fl;

                            // use next entry in SWP array
                            cSwpNewUsed++;

                            // set FS_NOMOVEWITHOWNER temporarily
                            // (moved this down V1.0.3 (2004-03-11) [umoeller]
                            if (     (!strcmp(pEntryThis->data.szClassName, "#1")
                                  && (!(WinQueryWindowULong(pEntryThis->data.swctl.hwnd, QWL_STYLE)
                                                & FS_NOMOVEWITHOWNER))
                                     )
                               )
                            {
                                pahwndNoMoveWithOwner[cNoMoveWithOwner++] = pEntryThis->data.swctl.hwnd;
                                WinSetWindowBits(pEntryThis->data.swctl.hwnd,
                                                 QWL_STYLE,
                                                 FS_NOMOVEWITHOWNER,
                                                 FS_NOMOVEWITHOWNER);
                            }

                        } // end if (    (pEntryThis->bWindowType == WINDOW_MAXIMIZE)...
                    }
                } // end while (pNode)
            } // end if (paswpNew = (PSWP)malloc(cbSwpNew))) etc.

            if (paswpNew)
            {
                if (cSwpNewUsed)
                {
                    // disable message processing in the hook
                    if (pgrLockHook(__FILE__, __LINE__, __FUNCTION__))
                    {
                        // now set all windows at once, this saves a lot of
                        // repainting...
                        fAnythingMoved = WinSetMultWindowPos(hab,
                                                             paswpNew,
                                                             cSwpNewUsed);
                        pgrUnlockHook();
                    }
                }

                // clean up SWP array
                free(paswpNew);
            } // if (paswpNew)

            // unset FS_NOMOVEWITHOWNER for the windows where we set it above
            while (cNoMoveWithOwner)
                WinSetWindowBits(pahwndNoMoveWithOwner[--cNoMoveWithOwner],
                                 QWL_STYLE,
                                 0,
                                 FS_NOMOVEWITHOWNER);

            pgrUnlockWinlist();
        }

        if (pahwndNoMoveWithOwner)
            free(pahwndNoMoveWithOwner);

        if (fAnythingMoved)
        {
            G_pHookData->ptlCurrentDesktop.x -= dx;
            G_pHookData->ptlCurrentDesktop.y -= dy;

            WinPostMsg(G_pHookData->hwndPagerClient,
                       PGRM_REFRESHCLIENT,
                       (MPARAM)FALSE,
                       0);

            if (flPager & PGRFL_FLASHTOTOP)
                WinSetWindowPos(G_pHookData->hwndPagerFrame,
                                HWND_TOP,
                                0, 0, 0, 0,
                                SWP_ZORDER | SWP_SHOW | SWP_RESTORE);

            brc = TRUE;
        }
    }

    return brc;
}
Example #18
0
 static void close(HWND hwnd)
 {
    HWND             frame = WinQueryWindow(hwnd,QW_PARENT);
    ICQFRAME         *cfg  = WinQueryWindowPtr(hwnd,0);
    SKINDATA         *skn;
    ICQMSGDIALOG     *msg  = NULL;
    ICQCONFIGDIALOG  *cgw  = NULL;

//    if(!cfg || cfg->sz != sizeof(ICQFRAME) || !cfg->icq)

    if(!(cfg && cfg->sz >= sizeof(ICQFRAME) && cfg->icq) )
    {
       DBGTracex(cfg);
       DBGTrace(cfg->sz);
       DBGTracex(cfg->icq);

       DBGMessage("***** ERROR CLOSING FRAME WINDOW *****");

       WinPostMsg(hwnd,WM_QUIT,0,0);
       return;
    }

    DBGMessage(cfg->name);
    if(*cfg->name)
       icqStoreWindow(frame, cfg->icq, 0, cfg->name);

    skn = icqskin_getDataBlock(cfg->icq);

    if(hwnd == skn->mainWindow)
    {
       if(skn->TrayServer)
          WinPostMsg(skn->TrayServer,WM_TRAYDELME,(MPARAM) skn->mainWindow,0);

       DBGMessage("Closing configuration windows");

       while(skn->firstCfgWin && skn->firstCfgWin != cgw)
       {
          cgw = skn->firstCfgWin;
          WinSendMsg(cgw->hwnd,WM_CLOSE,0,0);
       }
       DBGTracex(skn->firstCfgWin);

       DBGMessage("Closing message Windows");

       while(skn->firstMsgWin && skn->firstMsgWin != msg)
       {
          msg = skn->firstMsgWin;
          WinSendMsg(msg->hwnd,WM_CLOSE,0,0);
       }
       DBGTracex(skn->firstMsgWin);

       DBGMessage("Closing main Window");

       WinPostMsg(hwnd,WM_QUIT,0,0);
       return;
    }

    DBGMessage("Closing child window");

    WinDestroyWindow(frame);

 }
VOID GameThread(VOID *hpTempPipe)
{
   HPIPE   hpGamePipe;
   BOOL    fQuit=FALSE;
   PPIB    dummy;
   PTIB    ptibThrdInfo;
   ULONG   ulID;
   USHORT  usMsg, usData, GameBoard[DIVISIONS][DIVISIONS], usTotalMoves=0;

   /* save pipe handle in own memory */
   hpGamePipe = *(HPIPE *)hpTempPipe;

   /* get thread ID for use in displaying messages */
   if((BOOL)DosGetInfoBlocks(&ptibThrdInfo, &dummy))
   {
      ulID = 0;
   }

   else
   {
      ulID = ptibThrdInfo->tib_ptib2->tib2_ultid;
   }

   InitBoard(GameBoard);

   /* initialize random number generator */
   srand((unsigned) ulID);

   if(!(BOOL)DosConnectNPipe(hpGamePipe))
   {
      while (!fAppExit &&
             !fQuit &&
             !(BOOL)(Pipe_IO(CLIENT, hpGamePipe, &usMsg, &usData, ulID)) &&
             !fAppExit)
      {
         switch (usMsg)
         {
            case CLIENT_MOVE:
               /* enter move from message */
               *((USHORT *)GameBoard + usData) = CLIENT_NUM;
               usTotalMoves++;

               /* test for win if total moves >= DIVISIONS*2-1 */
               if (usTotalMoves >= DIVISIONS*2-1 &&
                   ((BOOL)(usData=WinTest(GameBoard)) ||
                    usTotalMoves == DIVISIONS*DIVISIONS))
               {
                  /* notify of win or draw, and break (switch) on return */
                  if (!usData)
                  {
                     usData = DIVISIONS*DIVISIONS;
                     usMsg = WIN_DRAW;
                  }

                  else
                  {
                     usMsg = WIN_CLIENT;
                  }

                  if ((BOOL)Pipe_IO(SERVER, hpGamePipe, &usMsg, &usData, ulID))
                  {
                     WinPostMsg(hwndMain, WM_MSG, MPFROMLONG(IDMSG_PIPE_WRITE_FAILED), MPVOID);
                     fQuit = TRUE;
                     break;
                  }

                  /* call InitBoard on win */
                  InitBoard(GameBoard);
                  usTotalMoves = 0;

                  break;  /* switch */
               }

               /* NO BREAK */

            case YOU_FIRST:
               /* get move if there are moves left */
               usData = GetMove(GameBoard, usTotalMoves);
               usTotalMoves++;

               /* test for win if total moves >= DIVISIONS*2-1 */
               if (usTotalMoves >= DIVISIONS*2-1 &&
                   ((BOOL)(usMsg=WinTest(GameBoard)) ||
                    usTotalMoves == DIVISIONS*DIVISIONS))
               {
                  /* write game_won message with winning move */
                  if (!usMsg)
                  {
                     usMsg = WIN_DRAW;
                  }

                  else
                  {
                     usMsg = WIN_SERVER;
                  }

                  if ((BOOL)Pipe_IO(SERVER, hpGamePipe, &usMsg, &usData, ulID))
                  {
                     WinPostMsg(hwndMain, WM_MSG, MPFROMLONG(IDMSG_PIPE_WRITE_FAILED), MPVOID);
                     fQuit = TRUE;
                     break;
                  }

                  /* call InitBoard on win */
                  InitBoard(GameBoard);
                  usTotalMoves = 0;
               }

               /* else */
               else
               {
                  /* write move to client */
                  usMsg = SERVER_MOVE;
                  if ((BOOL)Pipe_IO(SERVER, hpGamePipe, &usMsg, &usData, ulID))
                  {
                     WinPostMsg(hwndMain, WM_MSG, MPFROMLONG(IDMSG_PIPE_WRITE_FAILED), MPVOID);
                     fQuit = TRUE;
                  }
               }
               break;

            case ERROR_MSG:
               /* post the error to message queue */
               WinPostMsg(hwndMain, WM_MSG, MPFROMSHORT(usData), MPVOID);

            case CLIENT_QUIT:
               /* quit while */
               fQuit = TRUE;
         }
      }

      DosDisConnectNPipe(hpGamePipe);
   }

   DosClose(hpGamePipe);
}
Example #20
0
MRESULT EXPENTRY tBarProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  HENUM henum;
  RECTL rect;
  short height, i=0;
  HWND hwndHelp;
  char str[50];
  HPS hps;

  switch( msg )
  {
    case WM_CREATE:
    case WM_DESTROY:
    case WM_SIZE:
      break;

    case WM_COMMAND:
      WinSendMsg( WinQueryWindow( hwnd, QW_OWNER ), msg, mp1, mp2 );
      break;

    case TB_REDRAW:
      henum  = WinBeginEnumWindows( hwnd );

      while( (hwndHelp = WinGetNextWindow( henum )) != 0 )
      {
        WinSetWindowPos( hwndHelp, 0, i+2, 3, 0, 0, SWP_MOVE );
        WinQueryWindowRect( hwndHelp, &rect );
        i += rect.xRight;
      }

      break;

    case TB_ADDBUTTON:
      WinQueryWindowRect( hwnd, &rect );
      height = rect.yTop - rect.yBottom;

      sprintf( str, "#%ld", (ULONG)mp1 );

      hwndHelp = WinCreateWindow( hwnd, WC_BUTTON, str, WS_VISIBLE |
                                  BS_PUSHBUTTON | BS_BITMAP | BS_NOPOINTERFOCUS,
                                  0, 0, height-4, height-4,
                                  hwnd, HWND_BOTTOM, (ULONG)mp1, 0, NULL );

      oldButProc = WinSubclassWindow( hwndHelp, tButProc );

      WinPostMsg( hwnd, TB_REDRAW, 0, 0 );

      break;

    case TB_ADDSPACE:
      hwndHelp = WinCreateWindow( hwnd, WC_STATIC, NULL, !WS_VISIBLE,
                                  0, 0, (ULONG)mp1, 0,
                                  hwnd, HWND_BOTTOM, 0, 0, NULL );

      WinPostMsg( hwnd, TB_REDRAW, 0, 0 );

      break;

    case TB_SETBITMAP:
      sprintf( str, "#%ld", (ULONG)mp2 );
      hwndHelp = WinWindowFromID( hwnd, (USHORT)mp1 );
      WinSetWindowText( hwndHelp, (PSZ)str );
      WinPostMsg( hwnd, TB_REDRAW, 0, 0 );
      break;

    case TB_REMOVEBUTTONID:
      hwndHelp = WinWindowFromID( hwnd, (USHORT) mp1 );
      if( hwndHelp )
        WinDestroyWindow( hwndHelp );
      break;

    case TB_HWNDFROMID:
      return (MPARAM) WinWindowFromID( hwnd, (USHORT) mp1 );

    case WM_PAINT: {
      RECTL rcl;
      POINTL pt;

      HPS hps = WinBeginPaint( hwnd, 0, 0 );

      WinQueryWindowRect(hwnd,&rcl);
      WinFillRect( hps, &rcl, SYSCLR_BUTTONMIDDLE );

      pt.x = rcl.xLeft;
      pt.y = rcl.yBottom;
      GpiSetColor( hps, SYSCLR_BUTTONLIGHT );
      GpiMove( hps, &pt );
      pt.x = rcl.xRight - 1;
      GpiLine( hps, &pt );
      pt.x = rcl.xLeft;
      pt.y = rcl.yBottom + 1;
      GpiSetColor( hps, SYSCLR_BUTTONDARK );
      GpiMove( hps, &pt );
      pt.x = rcl.xRight - 1;
      GpiLine( hps, &pt );
      rcl.yBottom += 2;
      WinEndPaint( hps );
    }
    break;

    default:
      return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  }

  return FALSE;
}
// Message определяет пришедшее сообщение.
VOID Changer_ChangerMessageProcessing( PQMSG Message )
{
 // Устанавливаем приоритет потока.
 if( Message->msg == SM_PRIORITY )
  {
   // Устанавливаем приоритет.
   LONG Class = (LONG) Message->mp1;
   LONG Delta = (LONG) Message->mp2;
   DosSetPriority( PRTYS_THREAD, Class, Delta, 0 );

   // Запоминаем приоритет.
   Enhancer.Modules.Changer->Priority = MAKELONG( Class, Delta );
  }

 // Меняем значок окна.
 if( Message->msg == SM_CHANGE_ICON )
  {
   // Узнаем окно рамки.
   HWND Frame_window = (HWND) Message->mp1;
   // Узнаем значок, который должен быть установлен.
   HPOINTER New_icon = (HPOINTER) Message->mp2;

   // Если окна рамки нет - возврат.
   if( !WinIsWindow( WinQueryAnchorBlock( Frame_window ), Frame_window ) ) return;

   // Меняем значок.
   Changer_ChangeWindowIcon( Frame_window, New_icon );
  }

 // Сбрасываем значок, который был загружен с диска.
 if( Message->msg == SM_FREE_FILE_ICON )
  {
   // Узнаем значок.
   HPOINTER Icon = (HPOINTER) Message->mp1;

   // Освобождаем память.
   WinFreeFileIcon( Icon );
  }

 // Делаем окно доступным или недоступным для переключения.
 if( Message->msg == SM_SET_JUMPABLE )
  {
   // Узнаем окно рамки.
   HWND Frame_window = (HWND) Message->mp1;

   // Если окна рамки нет - возврат.
   if( !WinIsWindow( WinQueryAnchorBlock( Frame_window ), Frame_window ) ) return;

   // Узнаем свойство.
   ULONG Jumpable = (ULONG) Message->mp2;

   // Меняем его.
   if( Frame_window != GetDetectedShellWindow() ) SetJumpableFlag( Frame_window, Jumpable );
  }

 // Меняем шрифт для текстовых окон - первый и второй шаги.
 if( Message->msg == SM_CHANGE_VIO_FONT || Message->msg == SM_APPLY_VIO_FONT )
  {
   // Узнаем окно рамки.
   HWND Frame_window = (HWND) Message->mp1;

   // Если шрифт менять не надо - возврат.
   if( !VIOFontMustBeChanged( Frame_window ) ) return;

   // Если окна рамки нет - возврат.
   if( !WinIsWindow( WinQueryAnchorBlock( Frame_window ), Frame_window ) ) return;

   // Шаг первый: вызываем окно смены шрифта и ждем его появления.
   if( Message->msg == SM_CHANGE_VIO_FONT )
    {
     // Проверяем состояние окна.
     BYTE VIO_font_dialog = 0; FindProperty( Frame_window, PRP_VIO_FONT_DIALOG, &VIO_font_dialog );
     // Если для этого окна уже был вызван диалог выбора шрифта - возврат.
     if( VIO_font_dialog ) return;

     // Вызываем окно смены шрифта.
     OpenVIOFontMetricsDialog( Frame_window );

     // Запоминаем, что окно было показано.
     VIO_font_dialog = 1; SetProperty( Frame_window, PRP_VIO_FONT_DIALOG, &VIO_font_dialog );
    }

   // Шаг второй: выбираем в нем шрифт и применяем его.
   if( Message->msg == SM_APPLY_VIO_FONT )
    {
     // Выбираем шрифт.
     SubmitVIOFontMetricsDialog( Frame_window );
    }
  }

 // Делаем окно видимым.
 if( Message->msg == SM_SHOW_AND_ARRANGE )
  {
   // Узнаем окно рамки.
   HWND Frame_window = (HWND) Message->mp1;

   // Если окна рамки нет - возврат.
   if( !WinIsWindow( WinQueryAnchorBlock( Frame_window ), Frame_window ) ) return;

   // Делаем окно видимым.
   if( !WinIsWindowVisible( Frame_window ) ) WinShowWindow( Frame_window, 1 );

   // Если надо выравнивать текстовые окна:
   if( ArrangeVIOWindows() )
    {
     // Посылаем в окно сообщение WM_MARK. Когда оно будет получено, окно можно будет выравнивать.
     WinPostMsg( Frame_window, WM_MARK, (MPARAM) MRK_ARRANGE_WINDOW, (MPARAM) SM_ARRANGE_VIO );
    }
  }

 // Возврат.
 return;
}
Example #22
0
/*********************  Start of window procedure  **********************/
MRESULT EXPENTRY MyWindowProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
{
  USHORT command;                       /* WM_COMMAND command value     */
  HPS    hps;                           /* Presentation Space handle    */
  RECTL  rc;                            /* Rectangle coordinates        */
  POINTL pt;                            /* String screen coordinates    */

  switch( msg )
  {
    case WM_CREATE:
      if( State == RUNNING ) break;
      /******************************************************************/
      /* Window initialization is performed here in WM_CREATE processing*/
      /* WinLoadString loads strings from the resource file.            */
      /******************************************************************/
      InitIt( "DSTD32", Hab, hwnd );
      ReDraw( hwnd );
      break;

    case WM_COMMAND:
      /******************************************************************/
      /* When the user chooses option 1, 2, or 3 from the Options pull- */
      /* down, the text string is set to 1, 2, or 3, and                */
      /* WinInvalidateRegion sends a WM_PAINT message.                  */
      /* When Exit is chosen, the application posts itself a WM_CLOSE   */
      /* message.                                                       */
      /******************************************************************/
      command = SHORT1FROMMP(mp1);      /* Extract the command value    */
      switch (command)
      {
        case ID_LOAD:
          if( State == RUNNING ) break;
          if( State != NONE ) {
              KillIt();
              State = NONE;
          }
          if( LoadIt() ) {
              State = LOADED;
          }
          ReDraw( hwnd );
          break;
        case ID_RUN:
          if( State == RUNNING ) break;
          State = RUNNING;
          ReDraw( hwnd );
          if( InHardMode ) {
              WinLockInput( 0, FALSE );
              InHardMode = FALSE;
          }
          State = RunIt() ? BROKE : TERMINATED;
          if( HardMode ) {
              WinLockInput( 0, TRUE );
              InHardMode = TRUE;
          }
          ReDraw( hwnd );
          break;
        case ID_KILL:
          if( State == RUNNING ) break;
          if( InHardMode ) {
              WinLockInput( 0, FALSE );
              InHardMode = FALSE;
          }
          if( State != NONE ) {
              KillIt();
              State = NONE;
          }
          ReDraw( hwnd );
          break;
        case ID_HARD:
          if( State == RUNNING ) break;
          HardMode = !HardMode;
          TellHardMode( HardMode ? (char)-1 : 0 );
          ReDraw( hwnd );
          break;
        case ID_EXITPROG:
          if( InHardMode ) {
              WinLockInput( 0, FALSE );
              InHardMode = FALSE;
          }
          if( State == RUNNING ) break;
          WinPostMsg( hwnd, WM_CLOSE, 0L, 0L );
          break;
        default:
          return WinDefWindowProc( hwnd, msg, mp1, mp2 );
      }
      break;
    case WM_ERASEBACKGROUND:
      /******************************************************************/
      /* Return TRUE to request PM to paint the window background       */
      /* in SYSCLR_WINDOW.                                              */
      /******************************************************************/
      return (MRESULT)( TRUE );
    case WM_PAINT:
      /******************************************************************/
      /* Window contents are drawn here in WM_PAINT processing.         */
      /******************************************************************/
                                        /* Create a presentation space  */
      hps = WinBeginPaint( hwnd, NULL, &rc );
      pt.x = 50; pt.y = 50;             /* Set the text coordinates,    */
      GpiSetColor( hps, CLR_NEUTRAL );         /* colour of the text,   */
      GpiSetBackColor( hps, CLR_BACKGROUND );  /* its background and    */
      GpiSetBackMix( hps, BM_OVERPAINT );      /* how it mixes,         */
                                               /* and draw the string...*/
      strcpy( WhatItIs[ State ] +HARD_POS, IsHardMode[ HardMode ] );
      GpiCharStringAt( hps, &pt, (LONG)strlen( WhatItIs[ State ] ), WhatItIs[ State ] );
      WinEndPaint( hps );                      /* Drawing is complete   */
      break;
    case WM_CLOSE:
      /******************************************************************/
      /* This is the place to put your termination routines             */
      /******************************************************************/
      if( State == RUNNING ) break;
      FiniIt();
      WinPostMsg( hwnd, WM_QUIT, 0L, 0L );  /* Cause termination        */
      break;
    default:
      /******************************************************************/
      /* Everything else comes here.  This call MUST exist              */
      /* in your window procedure.                                      */
      /******************************************************************/

      return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  }
  return FALSE;
}
Example #23
0
MRESULT EXPENTRY WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
//	static POINTS DragStartPtrPos;
    POINTL ptl;
    static char Row, Col;
    static BOOL HasMoved = FALSE;
    static BOOL IntroSoundPlayed = FALSE;
    static BOOL RealPaint = TRUE;           // indicates whether the board
				// has to be repainted or just copied
    INT aktscan;
    CHAR msgtext[256];
    ULONG ulResponse;
//	ERRORID errId;

	
    switch( msg ){
    case WM_CREATE:
	if( !InfoData.LoadHigh() ){	// get previously saved highscores
	    InfoData.ResetHigh();
	    WinMessageBox( HWND_DESKTOP, hwndMain,
			   "The file scores.dat " \
			   "(which is in the current directory) was somehow corrupted." \
			   " All Highscores will be reset to Zero.",
			   "Error when loading Highscores",
			   0, MB_OK | MB_INFORMATION );
	}

	// allocate memory for global variables; see GLOBALS struct in tgraph.h
	pg = new GLOBALS;
	// initialize globals to zero
	memset( pg, 0, sizeof( GLOBALS ));
	// store globals pointer into client window words; see WinRegisterClass
//    WinSetWindowULong( hwnd, QWL_USER, (ULONG) pg );

    wcprintf("1: %x", WinGetLastError( hab ) );
	DosCreateEventSem( NULL, &hevWaitAfterScan, 0, FALSE );
				// Sem is created in reset state
	DosCreateEventSem( NULL, &hevHiScoreWin, 0, FALSE );
	DosCreateEventSem( NULL, &hevWaitAfterSound, 0, FALSE );
	DosCreateEventSem( NULL, &hevWaitSoundReady, 0, TRUE );
				// Sem is created in posted state
	// hevWaitAfterScan and hewWaitAfterSound are used to indicate
	// when the respective WM_CREATE routines are done.
	// after that they are in posted state, as desired
            
	// initialize globals with important data
	pg->hab          = hab;
	pg->hwndClient   = hwnd;
	pg->hwndFrame    = WinQueryWindow( hwnd, QW_PARENT );
	pg->hwndTitlebar = WinWindowFromID( pg->hwndFrame, FID_TITLEBAR );
	pg->hwndMenubar  = WinWindowFromID( pg->hwndFrame, FID_MENU );
	// create graphics and sound threads
	pg->tidTSound = _beginthread( &threadsound, NULL, LEN_STACK, NULL );
	pg->tidTGraph = _beginthread( &threadgraph, NULL, LEN_STACK, NULL );
	DosWaitEventSem( hevWaitAfterSound, SEM_INDEFINITE_WAIT );
	WinPostMsg( pg->hwndTSound, WM_SOUND_INTRO, MPFROMHWND(hwnd), 0 );
	// wait for the sound's WM_CREATE
	DosWaitEventSem( hevWaitAfterScan, SEM_INDEFINITE_WAIT );
	// wait for the graphics' WM_CREATE
	InfoData.ShipsNotFound = GBoard.GetShipNumber();
	wcprintf("create: %x", WinGetLastError( hab ) );
	return (MRESULT)0;
			
    case WM_CONTROL:
	break;
    case WM_QUIT:
	break;
			
    case WM_CLOSE:	// this message is sent before WM_QUIT
	InfoData.SaveHigh( WinGetCurrentTime(hab) );
				// save the highscores and provide a random seed
	// get pointer to globals from window words
//    pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );
	// tell object windows to quit, then exit their threads
//			WinSendMsg( pg->hwndTGraph, WM_DESTROY, mp1, mp2 );
	WinPostMsg( pg->hwndTGraph, WM_QUIT, mp1, mp2 );
//			WinSendMsg( pg->hwndTSound, WM_DESTROY, mp1, mp2 );
	WinPostMsg( pg->hwndTSound, WM_QUIT, mp1, mp2 );
	DosCloseEventSem( hevWaitAfterScan );
	DosCloseEventSem( hevHiScoreWin );
	DosCloseEventSem( hevWaitAfterSound );
	DosCloseEventSem( hevWaitSoundReady );
	WriteProfile( hab );
	delete pg;
	return (MRESULT) 0;
	
    case WM_ERASEBACKGROUND:
	wcprintf("erasebackground");        
//	return (MRESULT) FALSE;
	return (MRESULT) TRUE;

    case WM_PAINT:
///////////////////////////////////
	    {
		RECTL rectl;
		WinQueryWindowRect( pg->hwndClient, &rectl );
wcprintf("Linienrechteck: Breite: %d H”he: %d", rectl.xRight, rectl.yTop );
		// test size:
		GpiSetColor( hpsGlob, CLR_RED );
		ptl.x = rectl.xLeft; ptl.y = rectl.yBottom;
		GpiMove( hpsGlob, &ptl );
		ptl.x = rectl.xRight; ptl.y = rectl.yTop;
		GpiLine( hpsGlob, &ptl );
	    }
///////////////////////////
	break;

    case WM_SIZE:
	wcprintf("main wnd function wm-size");
	RealPaint = TRUE;
	GBoard.SetPMBoardValues( SHORT1FROMMP( mp2 ), SHORT2FROMMP( mp2 ) );
	WndResize( hwnd );
	wcprintf("size: %x", WinGetLastError( hab ) );
	break;
			
    case WM_BEGINDRAG:
	WinSetCapture( HWND_DESKTOP, hwnd );	// capture the mouse pointer
	GBoard.SetfDrag( TRUE );	// indicate that mouse is being dragged
	GBoard.ResetFirstDraw();	// for initialization of drag op.
	fHideSquare = TRUE;
	WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd),
		    MPFROM2SHORT( 0, 0 ) );
//			GBoard.ShowPointerPos( hwnd, 0, 0 ); // removes the square
	ptl.x = SHORT1FROMMP(mp1);
	ptl.y = SHORT2FROMMP(mp1);
	Row = GBoard.GetBoardRow( ptl.y );	// starting point of drag
	Col = GBoard.GetBoardCol( ptl.x );	// operation; static!
	return (MRESULT)TRUE;
			
    case WM_MOUSEMOVE:
	if( GBoard.GetfDrag() ){	// if mouse is being dragged
	    WinSendMsg( pg->hwndTGraph, WM_DRAWDRAGLINE, mp1,
			MPFROM2SHORT( Row, Col ) );
	    HasMoved = TRUE;
	} else {		// mouse is moved normally
	    if( !fHideSquare )
		WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd),
			    mp1 );
//					GBoard.ShowPointerPos( hwnd, SHORT1FROMMP(mp1),
//														  SHORT2FROMMP(mp1));
	}
	break;	
    case WM_ENDDRAG:
	WinSetCapture( HWND_DESKTOP, NULLHANDLE ); // release the captured
				// mouse pointer
	if( HasMoved ){	// mousemove has actually been moved
	    WinSendMsg( pg->hwndTGraph, WM_MARKDRAGLINE,
			MPFROM2SHORT( Row, Col ), 0 );
	    HasMoved = FALSE;
	}
	GBoard.SetfDrag( FALSE );
	GBoard.ClearDrawPoint();	// because no square is drawn right now
	fHideSquare = FALSE;
	WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd),
		    mp1 );
//			GBoard.ShowPointerPos( hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));
				// draws square at the current ptr pos
	break;
			
    case WM_CHAR:	// key was pressed
	if( SHORT2FROMMP( mp2 ) != VK_SPACE ) break;	// only space is interesting
	if( GBoard.GetfDrag() ) break;	// do nothing while dragging
	if( !GBoard.GetfShowLines() ){	// lines not visible yet
	    GBoard.SetfShowLines( TRUE );
	    WinSendMsg( pg->hwndTGraph, WM_DISPLAYLINES, 0, 0 );
	}
	break;
			
    case WM_BUTTON1CLICK:
	if( !InfoData.ShipsNotFound ) break;	// game is finished
	ptl.x = (LONG)SHORT1FROMMP( mp1 );
	ptl.y = (LONG)SHORT2FROMMP( mp1 );
	Row = GBoard.GetBoardRow( ptl.y );
	Col = GBoard.GetBoardCol( ptl.x );
	if( !Row || !Col ) break;
	fHideSquare = TRUE;
	WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd),
		    MPFROM2SHORT( 0, 0 ) );
//			GBoard.ShowPointerPos( hwnd, 0, 0 );	// hides pointer square
	if(( aktscan = GBoard.GetDiscovered( Row, Col )) != -1 ){
	    WinSendMsg( pg->hwndTGraph, WM_DRAWPMPLACE, MPFROMHWND(hwnd),
			MPFROMSH2CH( MAKESHORT(Row, Col),
				     (CHAR)aktscan,(CHAR)TRUE));
// umstricken auf WinPostMsg												 
				// toggle Place display
	} else {	// scan Place
	    DosResetEventSem( hevWaitAfterScan, &ulResponse );
// DosBeep(500, 150 );				
	    WinPostMsg( pg->hwndTGraph, WM_GRAPH_SCAN, MPFROMHWND(hwnd),
			MPFROM2SHORT( Row, Col ) );
// DosBeep( 800, 150 );								
	    WinWaitEventSem( hevWaitAfterScan, SEM_INDEFINITE_WAIT );
// DosBeep( 1000, 150 );				
				// first the scanning sounds must be played (and finished)
	    aktscan = GBoard.Scan( Row, Col );
	    if( aktscan == GBoard.GetShipNumber() + 10 ){
		InfoData.ShipsNotFound--;
		WinPostMsg( pg->hwndTSound, WM_SOUND_FOUNDSHIP, MPFROMHWND(hwnd), 0 );
	    } else {
		if( aktscan )
		    WinPostMsg( pg->hwndTSound, WM_SOUND_FOUND,
				MPFROMHWND(hwnd), MPFROMLONG( aktscan ) );
		else	
		    WinPostMsg( pg->hwndTSound, WM_SOUND_FOUND0, MPFROMHWND(hwnd), 0 );
	    }
	    WinWaitEventSem( hevWaitAfterScan, SEM_INDEFINITE_WAIT );
				// waits until scanning is done, and only then displays the
				// field icon
//				hps = WinGetPS( hwnd );
	    WinSendMsg( pg->hwndTGraph, WM_DRAWPMPLACE, MPFROMHWND(hwnd),
			MPFROMSH2CH( MAKESHORT(Row, Col),
				     (CHAR)aktscan,(CHAR)TRUE));
// umstricken auf WinPostMsg
	    WinPostMsg( pg->hwndTGraph, WM_SHOWSTATUSLINE, 0, 0 );
				
//				ShowStatusLine( hps, GBoard.MovesNeeded(), InfoData.ShipsNotFound,
//									 GBoard.GetWinWidth(), GBoard.GetWinHeight() );
//				WinReleasePS( hps );
	    if( !InfoData.ShipsNotFound ){	// game is finished, all ships found
		Score = GBoard.MovesNeeded();
		if	( !InfoData.ReturnLastHigh()	// still space in the hiscore table
		|| Score < InfoData.ReturnLastHigh() ){	// player kicks last one out
				// player enters highscore table
		    WinPostMsg( pg->hwndTSound, WM_SOUND_NEWHISCORE, MPFROMHWND(hwnd), 0 );
		    WinWaitEventSem( hevHiScoreWin, SEM_INDEFINITE_WAIT );
				// waits until the NEWHISCORE sound is actually played
		    WinDlgBox( HWND_DESKTOP, hwnd, HighScoreDlgProc, (HMODULE)0,
			       IDR_HIGHSCOREDLG, NULL );
		    WinPostMsg( hwnd, WM_COMMAND,
				MPFROMSHORT(IDM_GAMEHIGH), (MPARAM)0 );
				// show highscore-table
		    DosResetEventSem( hevHiScoreWin, &ulResponse ); // resets the sem again
		} else {
		    WinPostMsg( pg->hwndTSound, WM_SOUND_LOST, MPFROMHWND(hwnd), 0 );
		    WinWaitEventSem( hevHiScoreWin, SEM_INDEFINITE_WAIT );
				// waits until the NEWHISCORE sound is actually played
		    sprintf( msgtext,
			     "You needed %d moves to find the lost ships. " \
			     "To enter the highscore list you need %d moves." \
			     " So try again!", Score, InfoData.ReturnLastHigh() - 1 );
		    WinMessageBox( HWND_DESKTOP, hwnd, msgtext, "Oh, Shit!", 0,
				   MB_OK | MB_INFORMATION | MB_HELP );
		}
	    }
	}
	fHideSquare = FALSE;
	WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd),
		    MPFROM2SHORT( ptl.x, ptl.y ) );
//			GBoard.ShowPointerPos( hwnd, ptl.x, ptl.y ); // redisplay ptr square
	break;
			
    case WM_BUTTON2CLICK:
	fHideSquare = TRUE;
	WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd),
		    MPFROM2SHORT( 0, 0 ) );
	ptl.x = (LONG)SHORT1FROMMP( mp1 );
	ptl.y = (LONG)SHORT2FROMMP( mp1 );
	Row = GBoard.GetBoardRow( ptl.y );
	Col = GBoard.GetBoardCol( ptl.x );
	WinSendMsg( pg->hwndTGraph, WM_DRAWPMMARK, MPFROMHWND(hwnd),
		    MPFROM2SHORT( Row, Col ) );
	fHideSquare = FALSE;
	WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd),
		    MPFROM2SHORT( ptl.x, ptl.y ) );
	break;
			
    case WM_COMMAND:
	switch( SHORT1FROMMP( mp1 ) ){
	case IDM_GAMENEW:
	    GBoard.NewGame();
	    InfoData.ShipsNotFound = GBoard.GetShipNumber();
	    RealPaint = TRUE;
	    WinInvalidateRect( hwnd, NULL, TRUE );
	    break;
	case IDM_GAMESETTINGS:
	    if( WinDlgBox( HWND_DESKTOP, hwndFrame,
			   GameSettingsDlgProc, (HMODULE)0,
			   IDR_GAMESETTINGSDLG, NULL ) ){
				// screen must be repainted
		RealPaint = TRUE;
		WinInvalidateRect( hwnd, NULL, TRUE );
	    }
	    break;
	case IDM_GAMEHIGH:
	    if( !WinDlgBox( HWND_DESKTOP, hwndFrame,
			    ShowHighDlgProc, (HMODULE)0,
			    IDR_SHOWHIGHDLG, NULL ) ){	// user requested "Clear"
		if( WinMessageBox( HWND_DESKTOP, hwndMain,
				   "Do you really want to eradicate all those " \
				   "arduously achieved highscores?",
				   "Clear Highscores",
				   0, MB_OKCANCEL | MB_WARNING ) == MBID_OK )
		    InfoData.ResetHigh();
	    }
	    break;
					
	case IDM_HELPINDEX:	// help index
	    WinSendMsg( hwndHelp, HM_HELP_INDEX, 0, 0 );
	    break;
					
	case IDM_HELPGENERAL:	// general help
	    WinSendMsg( hwndHelp, HM_EXT_HELP, 0, 0 );
	    break;
					
	case IDM_HELPEXTENDED:	// help on help (system page)
	    WinSendMsg( hwndHelp, HM_DISPLAY_HELP, 0, 0 );
	    break;
					
	case IDM_HELPKEYS:	// keys help
	    WinSendMsg( hwndHelp, HM_KEYS_HELP, 0, 0 );
	    break;
					
	
	case IDM_HELPPRODUCTINFO:
	    ulResponse = WinDlgBox( HWND_DESKTOP, hwndFrame,
				    ProdInfoDlgProc, (HMODULE)0,
				    IDR_PRODINFODLG, NULL );
	    break;		
	}
	break;

    case HM_QUERY_KEYS_HELP:                // system asks which page to display
	return MRFROMSHORT( PANEL_HELPKEYS );
	      
    case HM_HELPSUBITEM_NOT_FOUND:
	return (MRESULT)FALSE;
			
    case WM_USER_ACK:	// graphics task finished its work
//         DosBeep( 1000, 150 );
	switch( (ULONG)mp1 ){
	case WM_USER_PAINT:
	    WinQueryPointerPos( HWND_DESKTOP, &ptl );
	    WinMapWindowPoints( HWND_DESKTOP, hwnd, &ptl, 1);
	    fHideSquare = FALSE;
	    WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd),
			MPFROM2SHORT( ptl.x, ptl.y ) );
//					GBoard.ShowPointerPos( hwnd, ptl.x, ptl.y );
				// painting has finished, square can be displayed now
	    break;
	}
	break;	
    case WM_SOUND_ACK:
	switch( (ULONG)mp1 ){
	case WM_SOUND_INTRO:
	    break;
	}
	break;

			
    default:
	return (MRESULT)WinDefWindowProc( hwnd, msg, mp1, mp2 );
    }		// end switch( msg )
    return (MRESULT)WinDefWindowProc( hwnd, msg, mp1, mp2 );
}		// end MRESULT EXPENTRY WndProc()
MRESULT EXPENTRY newProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{

  switch (msg)
    {      
    case WM_CREATE:
      {
        PCREATESTRUCT pCreate=PVOIDFROMMP(mp2);

        /* Initialize the slider data */
        WinSetWindowUShort(hwnd, SLIDERARMWITH,20);
        WinSetWindowUShort(hwnd, SLIDERARMHEIGHT,10);
        /* Dimensions of slider. The slider active area is smaller than the window to
           allow drawing of active state. */
        WinSetWindowULong(hwnd, SLIDERCX,pCreate->cx-4);
        WinSetWindowULong(hwnd, SLIDERCY,pCreate->cy-4);
        WinSetWindowULong(hwnd, SLIDERX,2);
        WinSetWindowULong(hwnd, SLIDERY,2);
        WinSetWindowULong(hwnd, SLIDERARMPOS, 0);
        WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
        return (MRESULT)0;
      }
    case WM_SIZE:
      WinSetWindowULong(hwnd, SLIDERCX, SHORT1FROMMP(mp2)-4);
      WinSetWindowULong(hwnd, SLIDERCY, SHORT2FROMMP(mp2)-4);
      WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
      return (MRESULT)0;
    case WM_BUTTON1DOWN:
      {
        SHORT x=SHORT1FROMMP( mp1);
        SHORT y=SHORT2FROMMP( mp1);
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);

        if(x<lPos+usWidth && y<WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
           && y>WinQueryWindowUShort(hwnd, SLIDERY)) {
          WinSetWindowUShort(hwnd, PTRPOSINSLARM, x-lPos);
        }
        WinSetFocus(HWND_DESKTOP, hwnd);
      break;
      }
    case WM_FOCUSCHANGE:
      {
        HPS hps;
        RECTL rcl;
        POINTL ptl;

        if(SHORT1FROMMP(mp2)) {
          hps=WinGetPS(hwnd);
          WinQueryWindowRect(hwnd, &rcl);        
          GpiSetLineType(hps, LINETYPE_DOT);
          ptl.x=rcl.xLeft;
          ptl.y=rcl.yBottom;
          GpiMove(hps,&ptl);
          ptl.x=rcl.xRight-1;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yTop-1;
          GpiLine(hps,&ptl);
          ptl.x=rcl.xLeft;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yBottom;
          GpiLine(hps,&ptl);
          WinReleasePS(hps);
        }
        else {
          WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
        }

        break;
      }
    case WM_CHAR:
      if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
        /* We have the focus */
        if((SHORT1FROMMP(mp1) & (KC_VIRTUALKEY))==(KC_VIRTUALKEY)) {
          LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
          USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
          ULONG ulCx=WinQueryWindowULong(hwnd, SLIDERCX);
#if 0
          FILE* file;
          file=fopen("d:\\md.log","a");
          fprintf(file,"0x%x 0x%x \n",SHORT1FROMMP(mp1),SHORT2FROMMP(mp1) );
          fclose(file);
#endif
          /*(KC_KEYUP|KC_PREVDOWN|KC_VIRTUALKEY)*/
          switch(SHORT2FROMMP(mp2))
            {
            case VK_RIGHT:

              if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
                lPos+=2;
                if(lPos>ulCx-usWidth)
                  lPos=ulCx-usWidth;
                else {
                  WinPostMsg( hwnd,
                              SLM_SETSLIDERINFO,
                              MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                              MPFROMLONG( (LONG) lPos ));
                  if(SHORT1FROMMP(mp1) & KC_LONEKEY)
                    /* Post SLN_CHANGE notification */
                    WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
                                MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
                                MPFROMLONG(lPos));
                  else
                    /* Post SLN_SLIDERTRACK notification */
                    WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
                               MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
                               MPFROMLONG(lPos));
                  
                }
                WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
              }
              return (MRESULT)TRUE;
            case VK_LEFT:
              if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
                lPos-=2;
                if(lPos<0) {
                  lPos=0;
                }
                else {
                  WinPostMsg( hwnd,
                              SLM_SETSLIDERINFO,
                              MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                              MPFROMLONG( (LONG) lPos ));
                  /* Post SLN_CHANGE notification */
                  WinPostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_CONTROL,
                             MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
                   MPFROMLONG(WinQueryWindowULong(hwnd, SLIDERARMPOS)));

                }
                WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
              }
              return (MRESULT)TRUE;
            default:
              break;
            }
        }
      }
      break;
    case WM_BUTTON1MOTIONSTART:
      {
        SHORT x=SHORT1FROMMP( mp1);
        SHORT y=SHORT2FROMMP( mp1);
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);

        if(x<lPos+usWidth && y<WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
           && y>WinQueryWindowUShort(hwnd, SLIDERY)) {
          WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
          WinSetCapture(HWND_DESKTOP, hwnd);
        }
        break;
      }
    case WM_BUTTON1MOTIONEND:
      if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
        WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
        WinSetCapture(HWND_DESKTOP, NULLHANDLE);
        /* Post SLN_CHANGE notification */
        WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
                   MPFROMLONG(WinQueryWindowULong(hwnd, SLIDERARMPOS)));
      }
      break;
    case SLM_SETSLIDERINFO:
      switch(SHORT1FROMMP(mp1))
        {
          case SMA_SLIDERARMPOSITION:
            /*  SMA_RANGEVALUE only for now !! */
            if(SHORT2FROMMP(mp1)==SMA_RANGEVALUE) {
              WinSetWindowULong(hwnd, SLIDERARMPOS, LONGFROMMP(mp2));
              WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
              return (MRESULT)0;
            }
            break;
        default:
          break;
        }
      break;
    case WM_MOUSEMOVE:
      if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
        HPS hps;
        RECTL rcl, rcl2, rcl3;
        LONG lTemp;
        SHORT x=SHORT1FROMMP(mp1);
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
       
        lTemp=lPos;
     
        rcl.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
        rcl.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
        rcl.xRight=rcl.xLeft+WinQueryWindowULong(hwnd, SLIDERCX);
        rcl.yTop=rcl.yBottom+WinQueryWindowULong(hwnd, SLIDERCY);

        rcl2=rcl3=rcl;
        rcl.xLeft=x-WinQueryWindowUShort(hwnd, PTRPOSINSLARM);
        if(rcl.xLeft<rcl2.xLeft)/* Make sure we stop at the left border */
          rcl.xLeft=rcl2.xLeft;

        rcl.xRight=rcl.xLeft+usWidth;
        if(rcl.xRight>rcl2.xRight)
          {/* Make sure we stop at the right border */
            rcl.xRight=rcl2.xRight;
            rcl.xLeft=rcl.xRight-usWidth;
          }
        lPos=rcl.xLeft-WinQueryWindowULong(hwnd, SLIDERX);/* Save position zero based */
        WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
        if(lPos!=lTemp) {
          BOOL rc;

          hps=WinGetPS(hwnd);
          /* Paint Background not necessary here */

          /* Shaft */
          /* Left part */
          rcl3.xRight=rcl.xLeft;
          rc=FALSE;
          if(USERSLIDER) {
            OWNERITEM oi={0};
            oi.hwnd=hwnd;
            oi.hps=hps;
            oi.fsState=SLS_OWNERDRAW;/* More to come */
            oi.rclItem=rcl3;
            oi.idItem=SDA_SLIDERSHAFT;
            rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                                MPFROMP(&oi) );
          }
          if(!rc)
            WinFillRect(hps, &rcl3, CLR_GREEN);

          /* Right part */
          rcl3.xRight=rcl2.xRight;
          rcl3.xLeft=rcl.xRight;
          rc=FALSE;
          if(USERSLIDER) {
            OWNERITEM oi={0};
            oi.hwnd=hwnd;
            oi.hps=hps;
            oi.fsState=SLS_OWNERDRAW;/* More to come */
            oi.rclItem=rcl3;
            oi.idItem=SDA_SLIDERSHAFT;
            rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                                MPFROMP(&oi) );
          }
          if(!rc)
            WinFillRect(hps, &rcl3, CLR_WHITE);

          /* Paint Slider */
          rc=FALSE;
          if(USERSLIDER) {
            OWNERITEM oi={0};
            oi.hwnd=hwnd;
            oi.hps=hps;
            oi.fsState=SLS_OWNERDRAW;/* More to come */
            oi.rclItem=rcl;
            oi.idItem=SDA_SLIDERARM;
            rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                                MPFROMP(&oi) );
          }
          if(!rc)
            {
              WinFillRect(hps,&rcl, CLR_BLUE);
              WinDrawBorder(hps, &rcl, 2, 2, 0, 0 ,0x0400);
            }

          WinReleasePS(hps);

          /* Post SLN_SLIDERTRACK notification */
          WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
                     MPFROMLONG(lPos));
        }
      }
      break;
    case WM_PAINT:
      {
        HPS hps, hps2;
        RECTL rcl, rcl2, rcl3;
        POINTL ptl;
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
        BOOL rc;

        WinQueryWindowRect(hwnd, &rcl);

        /* Shaft */
        rcl2.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
        rcl2.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
        rcl2.xRight=rcl2.xLeft+WinQueryWindowULong(hwnd, SLIDERCX)-1;
        rcl2.yTop=rcl2.yBottom+WinQueryWindowULong(hwnd, SLIDERCY)-1;

        /* Background */
        hps2=WinGetPS(hwnd);
        GpiExcludeClipRectangle(hps2,&rcl2);
        WinFillRect(hps2, &rcl, CLR_PALEGRAY);
        WinReleasePS(hps2);
        rcl2.yTop+=1;
        rcl2.xRight+=1;

        hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE);
        /* Focus */
        if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
          GpiSetLineType(hps, LINETYPE_DOT);
          ptl.x=rcl.xLeft;
          ptl.y=rcl.yBottom;
          GpiMove(hps,&ptl);
          ptl.x=rcl.xRight-1;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yTop-1;
          GpiLine(hps,&ptl);
          ptl.x=rcl.xLeft;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yBottom;
          GpiLine(hps,&ptl);
        }

        rcl3=rcl=rcl2;

        /* Arm pos */        
        rcl2.xLeft+=lPos;
        /* Arm size */        
        rcl2.xRight=rcl2.xLeft+usWidth;
        
        /* Shaft */
        /* Left part */
        rcl3.xRight=rcl2.xLeft;
        rc=FALSE;
        if(USERSLIDER) {
          OWNERITEM oi={0};
          oi.hwnd=hwnd;
          oi.hps=hps;
          oi.fsState=SLS_OWNERDRAW;/* More to come */
          oi.rclItem=rcl3;
          oi.idItem=SDA_SLIDERSHAFT;
          rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                    MPFROMP(&oi) );
        }
        if(!rc)
          WinFillRect(hps, &rcl3, CLR_GREEN);

        /* Right part */
        rcl3.xRight=rcl.xRight;
        rcl3.xLeft=rcl2.xRight;
        rc=FALSE;
        if(USERSLIDER) {
          OWNERITEM oi={0};
          oi.hwnd=hwnd;
          oi.hps=hps;
          oi.fsState=SLS_OWNERDRAW;/* More to come */
          oi.rclItem=rcl3;
          oi.idItem=SDA_SLIDERSHAFT;
          rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                              MPFROMP(&oi) );
        }
        if(!rc)
          WinFillRect(hps, &rcl3, CLR_WHITE);

        rc=FALSE;
        if(USERSLIDER) {
          OWNERITEM oi={0};
          oi.hwnd=hwnd;
          oi.hps=hps;
          oi.fsState=SLS_OWNERDRAW;/* More to come */
          oi.rclItem=rcl2;
          oi.idItem=SDA_SLIDERARM;
          rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                              MPFROMP(&oi) );
        }
        if(!rc)
          {
            WinFillRect(hps,&rcl2, CLR_BLUE);        
            WinDrawBorder(hps, &rcl2, 2, 2, 0, 0 ,0x0400);
          }

        WinEndPaint(hps);
        return (MRESULT)0;
      }
      break;
    default:
      break;
    }

  return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY Placement_Settings_WndProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 // Указатель на страницу.
 PPAGE Page = Enhancer.Pages.Placement_settings;

 // Проверяем сообщение.
 switch( Message )
  {
   // Отображаем настройки.
   case SM_SHOW_SETTINGS:
    {
     BYTE Value = 0; if( Arranger.Settings.Arrange_VIO_windows ) Value = 1;
     WinSendDlgItemMsg( Window, Placement_Settings.Settings.VIO_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );
     WinEnableWindow( WinWindowFromID( Window, Placement_Settings.Settings.FC2_button_ID ), Value );

     Value = 0; if( Arranger.Settings.Arrange_FC2_windows ) Value = 1;
     WinSendDlgItemMsg( Window, Placement_Settings.Settings.FC2_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Arranger.Settings.Arrange_WindowList ) Value = 1;
     WinSendDlgItemMsg( Window, Placement_Settings.Settings.WindowList_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Arranger.Settings.Arrange_WPS_windows ) Value = 1;
     WinSendDlgItemMsg( Window, Placement_Settings.Settings.WPS_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Arranger.Settings.Arrange_Browser_windows ) Value = 1;
     WinSendDlgItemMsg( Window, Placement_Settings.Settings.Browser_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );
    }
   return 0;

   // Следим за полями ввода.
   case WM_CONTROL:
    {
     ULONG WM_Control_Window_ID = SHORT1FROMMP( First_parameter );
     ULONG WM_Control_Action_ID = SHORT2FROMMP( First_parameter );

     if( WM_Control_Window_ID == Placement_Settings.Settings.VIO_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Arranger.Settings.Arrange_VIO_windows = 0;
           else Arranger.Settings.Arrange_VIO_windows = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Placement_Settings.Settings.FC2_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Arranger.Settings.Arrange_FC2_windows = 0;
           else Arranger.Settings.Arrange_FC2_windows = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Placement_Settings.Settings.WindowList_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Arranger.Settings.Arrange_WindowList = 0;
           else Arranger.Settings.Arrange_WindowList = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Placement_Settings.Settings.WPS_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Arranger.Settings.Arrange_WPS_windows = 0;
           else Arranger.Settings.Arrange_WPS_windows = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Placement_Settings.Settings.Browser_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Arranger.Settings.Arrange_Browser_windows = 0;
           else Arranger.Settings.Arrange_Browser_windows = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }
    }
   return 0;

   // Обрабатываем нажатия на кнопки.
   case WM_COMMAND:
    {
     ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter );

     if( WM_Control_Button_ID == OK_BUTTON_ID )
      {
       CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
       HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

       if( Ini_file )
        {
         PrfWriteProfileData( Ini_file, "Settings", "Arrange VIO windows", &Arranger.Settings.Arrange_VIO_windows,  sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Arrange FC2 windows", &Arranger.Settings.Arrange_FC2_windows,  sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Arrange WindowList",  &Arranger.Settings.Arrange_WindowList,   sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Arrange WPS windows", &Arranger.Settings.Arrange_WPS_windows,  sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Arrange Browsers", &Arranger.Settings.Arrange_Browser_windows, sizeof( BYTE ) );

         PrfCloseProfile( Ini_file );

         BroadcastRSMessages();
         NiceReadSettings();
        }
      }

     if( WM_Control_Button_ID == PD_BUTTON_ID )
      {
       if( Page->SetDefSettings ) Page->SetDefSettings( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext1 ) Page->SetDefSettings_Ext1( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext2 ) Page->SetDefSettings_Ext2( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext3 ) Page->SetDefSettings_Ext3( Page->Settings_to_show );

       WinPostMsg( Window, WM_COMMAND, (MPARAM) OK_BUTTON_ID, 0 );
      }

     if( WM_Control_Button_ID == HP_BUTTON_ID )
      {
       Help( Page->Settings_to_show, Enhancer.Code_page );
      }
    }
   return 0;
  }

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}
/* This Proc handles the on-the-fly data CD writing */
MRESULT EXPENTRY waveinfoStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  char text[CCHMAXPATH*2 +10];
  char title[CCHMAXPATH];
  SWCNTRL swctl;
  PID pid;
  int a;


  switch (msg)
    {
    case WM_PAINT:
      {
        HPS hps;
        RECTL rcl, rclSource;
        POINTL ptl;
        LONG lTemp;
        BOOL bUseCustomPainting=TRUE;
        LONG lWidthX;
        LONG lWidthY;
        LONG  lColor;
        ULONG attrFound;


        if(bUseCustomPainting) {
          //          if(allBMPs[CTRLIDX_BG].hbm) {
          if(1) {
            hps=WinBeginPaint(hwnd, NULLHANDLE, &rcl);
            rclSource.xLeft=0;
            rclSource.yBottom=0;
#if 0
            rclSource.yTop=allBMPs[CTRLIDX_BG].bmpInfoHdr.cy;
            rclSource.xRight=allBMPs[CTRLIDX_BG].bmpInfoHdr.cx;
            lTemp=rcl.xLeft/rclSource.xRight;
            ptl.x=lTemp*rclSource.xRight;
            lTemp=rcl.yBottom/rclSource.yTop;
            lTemp*=rclSource.yTop;
#endif

            //    rcl.yBottom+=4;
            rclSource=rcl;
            rcl.yTop+=4;
            WinFillRect(hps, &rclSource, CLR_RED);

            /* Border */
            lWidthX=WinQuerySysValue(HWND_DESKTOP, SV_CXBORDER);
            lWidthY=WinQuerySysValue(HWND_DESKTOP, SV_CYBORDER);

            GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
#if 0
        if ( (WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, &attrFound, sizeof(attrFound),
                                                &lColor, QPF_PURERGBCOLOR)) == 0 )
           lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
#endif

            WinQueryWindowRect(hwnd, &rcl);
            ptl.x=1;
            ptl.y=0;
            GpiMove(hps, &ptl);
            GpiSetColor(hps, CLR_BLACK);
            ptl.x=rcl.xRight-1;
            GpiLine(hps,&ptl);
            ptl.y=rcl.yTop-1;
            GpiLine(hps,&ptl);
            GpiSetColor(hps, SYSCLR_SHADOW);
            ptl.x=rcl.xLeft;
            GpiLine(hps,&ptl);
            ptl.y=0;
            GpiLine(hps,&ptl);

            rcl.yTop-=1;
            rcl.yBottom+=1;
            rcl.xLeft+=1;
            rcl.xRight-=1;

            WinDrawBorder( hps,&rcl, 1, 1, 0, 0, 0x400);
            rcl.yTop-=1;
            rcl.yBottom+=1;
            rcl.xLeft+=1;
            rcl.xRight-=1;

            /* Get active border color */
            if(WinQueryActiveWindow(HWND_DESKTOP)==hwnd) {
              if ( (WinQueryPresParam(hwnd, PP_BORDERCOLOR, 0, &attrFound, sizeof(attrFound),
                                      &lColor, QPF_PURERGBCOLOR)) == 0 )
                lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
            }
            else {
              /* Inactive border color */
              if ( (WinQueryPresParam(hwnd, PP_INACTIVECOLOR, 0, &attrFound, sizeof(attrFound),
                                      &lColor, QPF_PURERGBCOLOR)) == 0 )
                lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
            }
            /*            Get Border size */
            WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP(&ptl),0);

            WinDrawBorder(hps,&rcl, ptl.x-2, ptl.y-2, lColor, 0, 0);

#if 0
            while(ptl.x<rcl.xRight) {
              ptl.y=lTemp;
              while(ptl.y<rcl.yTop) {/* y direction */
                //DosBeep(5000,100);
                WinDrawBitmap(hps, allBMPs[CTRLIDX_BG].hbm,
                              &rclSource, 
                              (PPOINTL)&ptl,
                              0, 0,
                              DBM_IMAGEATTRS);
                ptl.y+=allBMPs[CTRLIDX_BG].bmpInfoHdr.cy;
                //DosSleep(200);
              };
              ptl.x+=allBMPs[CTRLIDX_BG].bmpInfoHdr.cx; 
            };
#endif
            WinEndPaint(hps);
            return (MRESULT)0;
          }
        }
        break;
      }

    case WM_DRAWITEM:
      switch(SHORT1FROMMP(mp1))
        {
        case SLIDERID:
          return drawSlider(hwnd, msg, mp1, mp2, SHORT1FROMMP(mp1));
        default:
          break;
        }              
      break;
    case WM_INITDLG:
      /* Add switch entry */
      memset(&swctl,0,sizeof(swctl));
      WinQueryWindowProcess(hwnd,&pid,NULL);
      swctl.hwnd=hwnd;
      swctl.uchVisibility=SWL_VISIBLE;
      swctl.idProcess=pid;
      swctl.bProgType=PROG_DEFAULT;
      swctl.fbJump=SWL_JUMPABLE;
      WinAddSwitchEntry(&swctl);

#if 0      
      WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "",
                     "",
                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
#endif
      //      oldProc=WinSubclassWindow(WinWindowFromID(hwnd, IDST_TEXT), newProc);
      hwndNew=WinCreateWindow(hwnd, CLASS_NAME, "Title", WS_VISIBLE |WS_TABSTOP, 10,50, SLIDERID, 40, 
                              hwnd, HWND_TOP, SLIDERID, NULLHANDLE, NULLHANDLE);
      WinShowWindow(hwnd, TRUE);
      //      WinQueryWindowPos(hwndNew,&swpSl);
      return (MRESULT) TRUE;
      /* WM_APPTERMINATENOTIFY messages are sent from the helper programs e.g. format checker. */
    case WM_CLOSE:
      WinDismissDlg(hwnd,0);
      return FALSE;
    case WM_CONTROL:
      {
        switch(SHORT2FROMMP(mp1))
          {
          case SLN_SLIDERTRACK:
            {
              switch(SHORT1FROMMP(mp1))
                {
                case SLIDERID:
                  DosBeep(5000, 10);
                  break;
                default:
                  break;
                }/* switch */
              return (MRESULT) 0;
              break;
            }
          case SLN_CHANGE:
            {
              switch(SHORT1FROMMP(mp1))
                {
                case SLIDERID:
                  DosBeep(500, 100);
                  break;
                default:
                  break;
                }/* switch */
              return (MRESULT)TRUE;
            }
          default:
            break;
          }/* switch */
        break;
      }/* WM_CONTROL */
      
    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1))
        {
        case DID_OK:
          /* User pressed the OK button */
          WinPostMsg(hwnd,WM_CLOSE,0,0);
          break;
        case IDPB_RIGHT:
          WinPostMsg( WinWindowFromID(hwnd, SLIDERID),
                      SLM_SETSLIDERINFO,
                      MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                      MPFROMLONG( (LONG) 70 ));
          
          break;
        case IDPB_LEFT:
          WinPostMsg( WinWindowFromID(hwnd, SLIDERID),
                      SLM_SETSLIDERINFO,
                      MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                      MPFROMLONG( (LONG) 20 ));
          
          break;
        case IDPB_SIZE:
          {
            SWP swp;
              RXSTRING arg[2];                       /* argument string for REXX  */
              RXSTRING rexxretval;                /* return value from REXX    */
              APIRET   rc;                        /* return code from REXX     */
              SHORT    rexxrc = 0;                /* return code from function */
              char chrThis[20];
              char chrHwnd[20];

              char    *str = "These words will be swapped"; /* text to swap   */

#if 0
              RexxRegisterFunctionExe("CWRXFunc1", (PFN)rexxFunc1);
              

              sprintf(chrThis, "%d",123);
              sprintf(chrHwnd, "%d", WinQueryWindow(hwnd,QW_PARENT));

              /* By setting the strlength of the output RXSTRING to zero, we   */
              /* force the interpreter to allocate memory and return it to us. */
              /* We could provide a buffer for the interpreter to use instead. */
              rexxretval.strlength = 0L;          /* initialize return to empty*/
              
              MAKERXSTRING(arg[0], chrHwnd, strlen(chrHwnd));/* create input argument     */
              MAKERXSTRING(arg[1], chrThis, strlen(chrThis));/* create input argument     */

              /* Here we call the interpreter.  We don't really need to use    */
              /* all the casts in this call; they just help illustrate         */
              /* the data types used.                                          */
              rc=RexxStart((LONG)      2,             /* number of arguments   */
                           (PRXSTRING)  &arg,          /* array of arguments    */
                           (PSZ)        "G:\\Projects_working\\mmclasses-0.3.0\\testfunc.cwr",/* name of REXX file     */
                           (PRXSTRING)  0,             /* No INSTORE used       */
                           (PSZ)        "CWRXX",         /* Command env. name     */
                           (LONG)       RXSUBROUTINE,  /* Code for how invoked  */
                           (PRXSYSEXIT) 0,             /* No EXITs on this call */
                           (PSHORT)     &rexxrc,       /* Rexx program output   */
                           (PRXSTRING)  &rexxretval ); /* Rexx program output   */

              sprintf(text,"rc: %d, function return code: %d, %s ", 
                      rc, (int) rexxrc, rexxretval.strptr);

              WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE);
              
              DosFreeMem(rexxretval.strptr);          /* Release storage       
                                                         given to us by REXX.  */
              
#endif

              //            WinQueryWindowPos(hwndNew,&swp);
              //    WinSetWindowPos(hwndNew, NULLHANDLE, 0, 0, swp.cx-30, swp.cy+10,SWP_SIZE);
          break;
          }
        default:
          break;
        }
      return (MRESULT) FALSE;
    default:
      break;
    }/* switch */
  
  return WinDefDlgProc( hwnd, msg, mp1, mp2);
}
Example #27
0
/*****************************************************************************
 * Control: control facility for the vout
 *****************************************************************************/
static int Control( vout_display_t *vd, int query, va_list args )
{
    vout_display_sys_t *sys = vd->sys;

    switch (query)
    {
    case VOUT_DISPLAY_HIDE_MOUSE:
    {
        POINTL ptl;

        WinQueryPointerPos( HWND_DESKTOP, &ptl );
        if( WinWindowFromPoint( HWND_DESKTOP, &ptl, TRUE ) == sys->client )
        {
            WinShowPointer( HWND_DESKTOP, FALSE );
            sys->is_mouse_hidden = true;
        }

        return VLC_SUCCESS;
    }

    case VOUT_DISPLAY_CHANGE_FULLSCREEN:
    {
        vout_display_cfg_t cfg = *va_arg(args, const vout_display_cfg_t *);

        if( sys->parent_window )
            vout_window_SetFullScreen(sys->parent_window, cfg.is_fullscreen);
        else
            WinPostMsg( sys->client, WM_VLC_FULLSCREEN_CHANGE,
                        MPFROMLONG( cfg.is_fullscreen ), 0 );

        return VLC_SUCCESS;
    }

    case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
    {
        const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
        bool  is_forced = va_arg(args, int);

        if( is_forced )
        {
            if( sys->parent_window )
            {
                vout_window_SetSize(sys->parent_window,
                                    cfg->display.width, cfg->display.height);

                /* Workaround :
                 * If changing aspect ratio after resizing a main window,
                 * an embedded window is misplaced. So reposition it, here.
                 */
                WinSetWindowPos( WinQueryWindow( sys->parent, QW_PARENT ),
                                 HWND_TOP, 0, 1, 0, 0, SWP_MOVE );
                WinSetWindowPos( WinQueryWindow( sys->parent, QW_PARENT ),
                                 HWND_TOP, 0, 0, 0, 0, SWP_MOVE );
            }
            else
                WinPostMsg( sys->client, WM_VLC_SIZE_CHANGE,
                            MPFROMLONG( cfg->display.width ),
                            MPFROMLONG( cfg->display.height ));
        }

        return VLC_SUCCESS;
    }

    case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
    case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
    {
        const video_format_t *source = va_arg(args, const video_format_t *);

        if( query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT )
        {
            sys->kvas.ulAspectWidth  = ( int64_t )source->i_width *
                                       source->i_sar_num / source->i_sar_den;
            sys->kvas.ulAspectHeight = source->i_height;
        }
        else
        {
            sys->kvas.rclSrcRect.xLeft   = source->i_x_offset;
            sys->kvas.rclSrcRect.yTop    = source->i_y_offset;
            sys->kvas.rclSrcRect.xRight  = source->i_x_offset +
                                           source->i_visible_width;
            sys->kvas.rclSrcRect.yBottom = source->i_y_offset +
                                           source->i_visible_height;
        }

        kvaSetup( &sys->kvas );

        return VLC_SUCCESS;
    }

    case VOUT_DISPLAY_RESET_PICTURES:
    case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
    case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
    case VOUT_DISPLAY_CHANGE_ZOOM:
    case VOUT_DISPLAY_GET_OPENGL:
        /* TODO */
        break;
    }

    msg_Err(vd, "Unsupported query(=%d) in vout display KVA", query);
    return VLC_EGENERIC;
}
Example #28
0
/* ARGSUSED5 */  /* Only Win32 uses gameMode parameter. */
GLUTwindow *
__glutCreateWindow(GLUTwindow * parent,
  int x, int y, int width, int height, int gameMode)
{
  GLUTwindow *window;
  XSetWindowAttributes wa;
  unsigned long attribMask;
  int winnum;
  int i;
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
  GLXFBConfigSGIX fbc;
#else
  void *fbc;
#endif

#if defined(__OS2PM__)
 {
    extern HAB   hab;      /* PM anchor block handle         */
    CLASSINFO classinfo;

    if(!WinQueryClassInfo(hab,"GLUT", &classinfo) )
                               __glutOpenOS2Connection(NULL);
  }
#elif defined(_WIN32)
  WNDCLASS wc;
  int style;

  if (!GetClassInfo(GetModuleHandle(NULL), "GLUT", &wc)) {
    __glutOpenWin32Connection(NULL);
  }
#else
  if (!__glutDisplay) {
    __glutOpenXConnection(NULL);
  }
#endif

#ifndef __OS2PM__
  if (__glutGameModeWindow) {
    __glutFatalError("cannot create windows in game mode.");
  }
#endif

  winnum = getUnusedWindowSlot();
  window = (GLUTwindow *) malloc(sizeof(GLUTwindow));
  if (!window) {
    __glutFatalError("out of memory.");
  }
  window->num = winnum;

#if defined(__OS2PM__)
  /* Add this new window to the window list. */
  __glutWindowList[winnum] = window;
  window->shownState = -1;
#endif

#if !defined(_WIN32)  && !defined(__OS2PM__)
  window->vis = __glutDetermineWindowVisual(&window->treatAsSingle,
    &window->visAlloced, (void**) &fbc);
  if (!window->vis) {
    __glutFatalError(
      "visual with necessary capabilities not found.");
  }
  __glutSetupColormap(window->vis, &window->colormap, &window->cmap);
#endif
  window->eventMask = StructureNotifyMask | ExposureMask;

  attribMask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
  wa.background_pixmap = None;
  wa.border_pixel = 0;
  wa.colormap = window->cmap;
  wa.event_mask = window->eventMask;
  if (parent) {
    if (parent->eventMask & GLUT_HACK_STOP_PROPAGATE_MASK)
      wa.event_mask |= GLUT_HACK_STOP_PROPAGATE_MASK;
    attribMask |= CWDontPropagate;
    wa.do_not_propagate_mask = parent->eventMask & GLUT_DONT_PROPAGATE_FILTER_MASK;
  } else {
    wa.do_not_propagate_mask = 0;
  }

  /* Stash width and height before Win32's __glutAdjustCoords
     possibly overwrites the values. */
  window->width = width;
  window->height = height;
  window->forceReshape = True;
  window->ignoreKeyRepeat = False;

#if defined(__OS2PM__)

 {  ULONG flStyle=0;
    int ii;
    ERRORID  erridErrorCode;/* last error id code */
    extern HAB   hab;      /* PM anchor block handle         */

  if (parent) {
    flStyle = WS_CLIPCHILDREN|WS_VISIBLE;
  } else {
    if (gameMode) {
      /* Game mode window should be a WS_POPUP window to
         ensure that the taskbar is hidden by it.  A standard
         WS_OVERLAPPEDWINDOW does not hide the task bar. */
      flStyle = FCF_STANDARD |  WS_MAXIMIZED;
    } else {
      /* A standard toplevel window with borders and such. */
      flStyle = FCF_STANDARD | WS_CLIPCHILDREN;
//      flStyle = WS_OVERLAPPEDWINDOW;
    }
  }
{
 HWND  hwnd;                           /* Window     */
 ULONG ListBoxId;                      /* Window id  */
                                       /* (supplied by application) */


 HWND hwndClient;        /* handle to the client                 */
 HWND hwndFrame;         /* handle to the frame                  */
 PFNWP GenericWndProc;
 FRAMECDATA  fcd;
 RECTL  rect;     /* Boundary rectangle                   */



/************************************************/
// flCreate = (FCF_STANDARD) & ~FCF_TASKLIST;
/**********************************/
  if (parent)
  {   window->frame = NULL;

 hwnd = WinCreateWindow(parent->win,  /* Parent window             */
                        "GLUTCHILD",        /* Class name                */
                        "",    /* Window text               */
                        flStyle,       /* Window style              */
                        x, y,          /* Position (x,y)            */
                        width, height,      /* Size (width,height)       */
                        parent->win,    /* Owner window              */
                        HWND_TOP,      /* Sibling window            */
                        0,             /* Window id                 */
                        NULL,          /* Control data              */
                        NULL);         /* Pres parameters           */

 erridErrorCode = WinGetLastError(hab);
    window->win = hwnd;

  window->hdc = WinOpenWindowDC(window->win);
  window->hpsBuffer = hpsCurrent;


 rect.xLeft = x;
 rect.xRight = x+width;
 rect.yBottom = y;
 rect.yTop = y + height;

/***** else parent *****************************/
  } else {
        hwnd = WinCreateStdWindow(HWND_DESKTOP,
           0,       /* WS_VISIBLE frame-window style        */
           &flStyle,        /* window style                 */
           "GLUT",          /* class name                   */
           "GLUT",/* window title                  */
            0L,                  /* default client style          */
            NULLHANDLE,          /* resource in executable file   */
            ID_WINDOW,           /* resource id                   */
            &hwndClient);        /* receives client window handle */

 erridErrorCode = WinGetLastError(hab);
       window->win = hwndClient;
       window->frame = hwnd;
  window->hdc = WinOpenWindowDC(window->win);

  window->hpsBuffer = hpsCurrent;


/* converts a client window's boundaries into  an equivalent frame rectangle */
 rect.xLeft = x;
 rect.xRight = x+width;
 rect.yBottom = y;
 rect.yTop = y + height;

 /* calculate equivalent frame boundary from boundary data */
  WinCalcFrameRect(window->frame, &rect, FALSE);
 }
/***** endof if(parent) *****************************/

  /* Must set the XHDC for fake glXChooseVisual & fake
     glXCreateContext & fake XAllocColorCells. */
  XHDC = window->hdc;
  XHWND = window->win;
  window->vis = __glutDetermineWindowVisual(&window->treatAsSingle,
    &window->visAlloced, &fbc);
    if (!window->vis)
    {   __glutFatalError(
        "pixel format with necessary capabilities not found.");
    }
    { int rc;
      rc = wglChoosePixelFormat(window->hdc, window->vis),

//     evglSetPixelFormat(2); /* int iPixelFormat 1 - doublebuffer/2 - single buffer ??*/
      wglSetPixelFormat(window->hdc,rc,window->vis);
    }
   __glutSetupColormap(window->vis, &window->colormap, &window->cmap);

  window->ctx = glXCreateContext(window->hpsBuffer, window->vis,
    None, __glutTryDirect);

  WinSetWindowPos(hwnd,
                  HWND_TOP,rect.xLeft,rect.yBottom,
                  rect.xRight-rect.xLeft, rect.yTop-rect.yBottom,
      SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW|SWP_ZORDER); /* flags*/

  /* Make sure subwindows get a windowStatus callback. */
  if (parent)
       WinPostMsg(parent->win, WM_ACTIVATE, 0, 0);

  }
}

#elif defined(_WIN32)

  __glutAdjustCoords(parent ? parent->win : NULL,
    &x, &y, &width, &height);
  if (parent) {
    style = WS_CHILD;
  } else {
    if (gameMode) {
      /* Game mode window should be a WS_POPUP window to
         ensure that the taskbar is hidden by it.  A standard
         WS_OVERLAPPEDWINDOW does not hide the task bar. */
      style = WS_POPUP | WS_MAXIMIZE;
    } else {
      /* A standard toplevel window with borders and such. */
      style = WS_OVERLAPPEDWINDOW;
    }
  }
  window->win = CreateWindow("GLUT", "GLUT",
    WS_CLIPSIBLINGS | WS_CLIPCHILDREN | style,
    x, y, width, height, parent ? parent->win : __glutRoot,
    NULL, GetModuleHandle(NULL), 0);
  window->hdc = GetDC(window->win);
  /* Must set the XHDC for fake glXChooseVisual & fake
     glXCreateContext & fake XAllocColorCells. */
  XHDC = window->hdc;
  window->vis = __glutDetermineWindowVisual(&window->treatAsSingle,
    &window->visAlloced, &fbc);
  if (!window->vis) {
    __glutFatalError(
      "pixel format with necessary capabilities not found.");
  }
  if (!SetPixelFormat(window->hdc,
      ChoosePixelFormat(window->hdc, window->vis),
      window->vis)) {
    __glutFatalError("SetPixelFormat failed during window create.");
  }
  __glutSetupColormap(window->vis, &window->colormap, &window->cmap);
  /* Make sure subwindows get a windowStatus callback. */
  if (parent) {
    PostMessage(parent->win, WM_ACTIVATE, 0, 0);
  }
  window->renderDc = window->hdc;
#else
  window->win = XCreateWindow(__glutDisplay,
    parent == NULL ? __glutRoot : parent->win,
    x, y, width, height, 0,
    window->vis->depth, InputOutput, window->vis->visual,
    attribMask, &wa);
#endif
  window->renderWin = window->win;
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
  if (fbc) {
    window->ctx = __glut_glXCreateContextWithConfigSGIX(__glutDisplay, fbc,
      GLX_RGBA_TYPE_SGIX, None, __glutTryDirect);
  } else
#endif
#if defined(__OS2PM__)
//    window->ctx = glXCreateContext(window->hpsBuffer, window->vis,
//      None, __glutTryDirect);
#else
    window->ctx = glXCreateContext(__glutDisplay, window->vis,
      None, __glutTryDirect);
#endif
  if (!window->ctx) {
    __glutFatalError(
      "failed to create OpenGL rendering context.");
  }
  window->renderCtx = window->ctx;
#if !defined(_WIN32) && !defined(__OS2PM__)
  window->isDirect = glXIsDirect(__glutDisplay, window->ctx);
  if (__glutForceDirect) {
    if (!window->isDirect)
      __glutFatalError("direct rendering not possible.");
  }
#endif

  window->parent = parent;
  if (parent) {
    window->siblings = parent->children;
    parent->children = window;
  } else {
    window->siblings = NULL;
  }
  window->overlay = NULL;
  window->children = NULL;
  window->display = __glutDefaultDisplay;
  window->reshape = __glutDefaultReshape;
  window->mouse = NULL;
  window->motion = NULL;
  window->passive = NULL;
  window->entry = NULL;
  window->keyboard = NULL;
  window->keyboardUp = NULL;
  window->windowStatus = NULL;
  window->visibility = NULL;
  window->special = NULL;
  window->specialUp = NULL;
  window->buttonBox = NULL;
  window->dials = NULL;
  window->spaceMotion = NULL;
  window->spaceRotate = NULL;
  window->spaceButton = NULL;
  window->tabletMotion = NULL;
  window->tabletButton = NULL;
#ifdef _WIN32
  window->joystick = NULL;
  window->joyPollInterval = 0;
#endif

#if defined(__OS2PM__)
  window->wm_command = NULL;
#endif

  window->tabletPos[0] = -1;
  window->tabletPos[1] = -1;
#if defined(__OS2PM__)
  if(window->shownState == -1)
           window->shownState = 0;
   window->visState =  window->shownState;
#else
  window->shownState = 0;
  window->visState = -1;  /* not VisibilityUnobscured,
                             VisibilityPartiallyObscured, or
                             VisibilityFullyObscured */
#endif
  window->entryState = -1;  /* not EnterNotify or LeaveNotify */

  window->desiredConfMask = 0;
  window->buttonUses = 0;
  window->cursor = GLUT_CURSOR_INHERIT;

  /* Setup window to be mapped when glutMainLoop starts. */
  window->workMask = GLUT_MAP_WORK;
#ifdef _WIN32
  if (gameMode) {
    /* When mapping a game mode window, just show
       the window.  We have already created the game
       mode window with a maximize flag at creation
       time.  Doing a ShowWindow(window->win, SW_SHOWNORMAL)
       would be wrong for a game mode window since it
       would unmaximize the window. */
    window->desiredMapState = GameModeState;
  } else {
    window->desiredMapState = NormalState;
  }
#else
  window->desiredMapState = NormalState;
#endif
  window->prevWorkWin = __glutWindowWorkList;
  __glutWindowWorkList = window;

  /* Initially, no menus attached. */
  for (i = 0; i < GLUT_MAX_MENUS; i++) {
    window->menu[i] = 0;
  }

  /* Add this new window to the window list. */
  __glutWindowList[winnum] = window;

  /* Make the new window the current window. */
  __glutSetWindow(window);

  __glutDetermineMesaSwapHackSupport();

  if (window->treatAsSingle) {
    /* We do this because either the window really is single
       buffered (in which case this is redundant, but harmless,
       because this is the initial single-buffered context
       state); or we are treating a double buffered window as a
       single-buffered window because the system does not appear
       to export any suitable single- buffered visuals (in which
       the following are necessary). */
    glDrawBuffer(GL_FRONT);
    glReadBuffer(GL_FRONT);
  }
  return window;
}
Example #29
0
 void EXPENTRY icqAjustTaskList(HICQ icq, HWND hwnd, const char *txt)
 {
    ULONG               sel             = icqQueryOnlineMode(icq);
    HMSG                msg             = NULL;
    ULONG               uin;
    int                 pos;
    int                 task            = icqLoadValue(icq,"TaskTITLE",0);
    char                *buffer         = NULL;

    CHKPoint();

    icqQueryFirstMessage(icq, &uin, &msg);

    DBGTracex(txt);

    buffer = malloc(1024);

    if(buffer)
    {
       if(task && txt)
       {
          CHKPoint();
          sprintf(buffer,"%lu - %s",icqQueryUIN(icq),txt);
       }
       else
       {
          sprintf(buffer,"%lu",icqQueryUIN(icq));

          switch(task)
          {
          case 0:                  // No change
             break;

          case 1:
             getTitleByMode(icq,sel,buffer);
             break;

          case 2:
             if(msg)
             {
                strncat(buffer," - ",0xFF);
                pos = strlen(buffer);
                CHKPoint();
                icqQueryMessageTitle(icq, uin, FALSE, msg, buffer + pos, 0xFF - pos);
                CHKPoint();
             }
             else
             {
                getTitleByMode(icq,sel,buffer);
             }
             break;
          }
       }
       DBGMessage(buffer);
       DBGTrace(strlen(buffer));

       WinSendMsg(hwnd,WM_USER+1040,(MPARAM) buffer, 0);

       CHKPoint();
       free(buffer);
    }
    else
    {
       icqWriteSysLog(icq,PROJECT,"Memory allocation error when changing window title");
    }

    switch(icqLoadValue(icq,"TaskICON",0))
    {
    case 0:		// No change
       break;

    case 1:		// By mode
       WinPostMsg(hwnd,WM_USER+1039,(MPARAM) getModeIcon(icq, sel), 0);
       break;

    case 2:		// By message
       if(msg && msg->mgr)
          WinPostMsg(hwnd,WM_USER+1039,(MPARAM) msg->mgr->icon[0], 0);
       else
          WinPostMsg(hwnd,WM_USER+1039,(MPARAM) getModeIcon(icq, sel), 0);
       break;

    }

    icqUpdateSysTray(icq);

    CHKPoint();
 }
Example #30
0
MRESULT mainwmControl( HWND hwnd, MPARAM mp1, MPARAM mp2 )
{
    switch (SHORT1FROMMP(mp1))
    {
    case ID_HANMLE:
//      printf("HMLEdit:: WM_CONTROL\n");
//      printf("notif = %x\n",SHORT2FROMMP(mp1));
        switch (SHORT2FROMMP(mp1))
        {
        case HMLN_CHANGED:
            WinPostMsg(hwndStatbar,STATBAR_USERM_SETMODIFIED,MPFROMLONG(TRUE),0L);
            if (WinSendMsg(hwndToolbar,TOOLBAR_USERM_ISITEMSHOWING,MPFROMLONG(TOOLBAR_RELOAD),0))
                DisableReloadButton(hwnd);
            break;
        case HMLN_BEGINSELECTION:
            markingState = TRUE;

            if (use_smarttoolbar) ShowEditButtons(hwnd);
            break;
        case HMLN_ENDSELECTION:
            markingState = FALSE;

            if (use_smarttoolbar) HideEditButtons(hwnd);
            break;
        case HMLN_KILLFOCUS:
            break;
        case HMLN_SETFOCUS:
            break;
        case HMLN_FILEDROP:
            {
            HMLEFILEDROPNOTIF *dropFileNotif = (HMLEFILEDROPNOTIF*)mp2;

            if (WinSendMsg(hwndHMLE,HMLM_QUERYCHANGED,0L,0L))
                {
                if (WinMessageBox(
                        HWND_DESKTOP,hwnd,
                        "Document changed. Discard it?","Caution",
                        0,MB_YESNO|MB_DEFBUTTON2|MB_WARNING|MB_MOVEABLE)==MBID_NO)
                    return 0L;
                }
            HEFileOpenWithAutoHanCode(hwnd,dropFileNotif->fullPath,TRUE);

            } break;
        case HMLN_NOTIFYCURSORPOS:
            {
                WinPostMsg(hwndStatbar,STATBAR_USERM_SETLINECOL,mp2,0L);
            } break;
        } // switch NotifiCode;
        break;
    case ID_HIA:
        switch (SHORT2FROMMP(mp1))
        {
        case HIAN_HANMODECHANGED:
            WinPostMsg(hwndStatbar,STATBAR_USERM_SETHANMODE,mp2,0L);
            break;
        case HIAN_KBDTYPECHANGED:
            WinPostMsg(hwndStatbar,STATBAR_USERM_SETKBDTYPE,mp2,0L);
            break;
        case HIAN_INSERTMODECHANGED:
            WinPostMsg(hwndStatbar,STATBAR_USERM_SETINSERTMODE,mp2,0L);
        } // switch NotifCode
        break;
    } // switch Control

    return MRFROMLONG(0L);
}