/****************************************************************************
   Main Program start
*****************************************************************************/
int main()
{
    HMQ   hmq;
    QMSG  qmsg;

    hab = WinInitialize (0);
    hmq = WinCreateMsgQueue (hab, 0);

    hWndFrame = WinLoadDlg (HWND_DESKTOP, HWND_DESKTOP,
        MainDlgProc, 0, IDD_CLOCK,NULL);
    TitleDefProc = WinSubclassWindow(WinWindowFromID(hWndFrame, FID_TITLEBAR),
                   (PFNWP)TitleBarProc );
    SysMenuDefProc = WinSubclassWindow(WinWindowFromID(hWndFrame, FID_SYSMENU),
                   (PFNWP)SysMenuProc );

    SysMenuButton = WinLoadPointer (HWND_DESKTOP, 0, IDD_CLOCK);
    WinQueryPointerInfo(SysMenuButton,&PointerInfo);
    WinSendMsg (hWndFrame, WM_SETICON, (MPARAM)SysMenuButton, NULL);


    while (WinGetMsg (hab, &qmsg, 0, 0, 0))
        WinDispatchMsg (hab, &qmsg);

    WinDestroyWindow (hWndFrame);
    WinDestroyMsgQueue (hmq);
    WinTerminate (hab);
    return (0);
}
示例#2
0
//----------------------------------------------------------------------------
// NPP_SetWindow:
//----------------------------------------------------------------------------
NPError NP_LOADDS
NPP_SetWindow(NPP instance, NPWindow* window) {
  pprintf( szPPR, "NPP_SetWindow\n\r" );
  if ( instance == 0 ) return NPERR_INVALID_INSTANCE_ERROR;

  PluginInstance* This = (PluginInstance*) instance->pdata;

  //
  // *Developers*: Before setting fWindow to point to the
  // new window, you may wish to compare the new window
  // info to the previous window (if any) to note window
  // size changes, etc.
  //

  // if window handle changed
  if ( This->hWnd != (HWND)window->window ) {
    pprintf( szPPR, "HWND (hmf %x) changed, %x --> %x\n\r", This->hmf, (int)This->hWnd, (int)window->window );
    // remember the new window
    This->fWindow = window;
    if ( This->hWnd ) {
      // Remove the subclass for the old client window
      WinSubclassWindow(This->hWnd, This->lpfnOldWndProc);
    }
    // remember the new window handle
    This->hWnd = (HWND)This->fWindow->window;
    // subclass the window
    This->lpfnOldWndProc = WinSubclassWindow(This->hWnd, SubClassFunc);
    AssociateInstance( This->hWnd, This );
    /* paint a background for the drawing */
    WinQueryWindowRect( This->hWnd, &This->rclWnd );
//    WinFillRect( This->hps, &This->rclWnd, CLR_PALEGRAY );
    // destroy old PS and create new PS
    if ( This->hps ) GpiDestroyPS( This->hps );
    HDC hdc = WinQueryWindowDC( This->hWnd );
    if ( !hdc ) hdc = WinOpenWindowDC( This->hWnd );
    SIZEL siz={ 0, 0 };
    HAB hab=WinQueryAnchorBlock( This->hWnd );
    This->hps = GpiCreatePS( hab, hdc, &siz,
                                  PU_PELS | GPIT_NORMAL | GPIA_ASSOC );
    pprintf( szPPR, "GpiCreatePS, hdc=%x, hps=%x\n\r", (int)hdc, (int)This->hps );
    if ( !This->hps ) {
      pprintf( szPPR, "GpiCreatePS failed, Err=%x\n\r",
        WinGetLastError( hab ) );
    }
    SetTransform( This, This->hps, &This->rclWnd );
  } else { // check if window coordinates changed.
           //It may happens for full-screan
    RECTL rcl;
    WinQueryWindowRect( This->hWnd, &rcl );
    if ( memcmp( &This->rclWnd, &rcl, sizeof( rcl ) ) ) {
      pprintf( szPPR, "Rect (hmf %x) changed, ( %d, %d ) - ( %d, %d ) --> ( %d, %d ) - ( %d, %d )\n\r",
        This->hmf,
        This->rclWnd.xLeft, This->rclWnd.yBottom, This->rclWnd.xRight, This->rclWnd.yTop,
        rcl.xLeft, rcl.yBottom, rcl.xRight, rcl.yTop );
      memcpy( &This->rclWnd, &rcl, sizeof( rcl ) );
      SetTransform( This, This->hps, &This->rclWnd );
    }
  }
  return NPERR_NO_ERROR;
}
extern MRESULT EXPENTRY ComboBox_Processor ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {

   static PWINDOWPROC DefaultProcessor = 0 ;

   switch ( msg ) {

      case WM_CREATE: {
         CLASSINFO ClassInfo ;
         WinQueryClassInfo ( WinQueryAnchorBlock(hwnd), WC_COMBOBOX, &ClassInfo ) ;
         DefaultProcessor = ClassInfo.pfnWindowProc ;
         MRESULT Result = DefaultProcessor ( hwnd, msg, mp1, mp2 ) ;
         HWND Entryfield = WinWindowFromID ( hwnd, CBID_EDIT ) ;
         ULONG Style = WinQueryWindowULong ( hwnd, QWL_STYLE ) ;
         if ( Style & CBS_DROPDOWNLIST ) {
            OldComboEntry_Processor1 = WinSubclassWindow ( Entryfield, ComboEntry_Processor1 ) ;
         } else {
            OldComboEntry_Processor2 = WinSubclassWindow ( Entryfield, ComboEntry_Processor2 ) ;
         } /* endif */
         return ( Result ) ; }

      case WM_CONTROL: {
         USHORT Id = WinQueryWindowUShort ( hwnd, QWS_ID ) ;
         SHORT Control = SHORT1FROMMP ( mp1 ) ;
         SHORT Message = SHORT2FROMMP ( mp1 ) ;
         switch ( Control ) {
            case CBID_EDIT: {
               switch ( Message ) {
                  case EN_SETFOCUS: {
                     Sys_SendMessage( OWNER(hwnd), WM_CONTROL, MPFROM2SHORT(Id,CBN_SETFOCUS), 0 ) ;
                     break; }
                  case EN_KILLFOCUS: {
                     Sys_SendMessage( OWNER(hwnd), WM_CONTROL, MPFROM2SHORT(Id,CBN_KILLFOCUS), 0 ) ;
                     break; }
               } /* endswitch */
               break; }
            case CBID_LIST: {
               switch ( Message ) {
                  case LN_SETFOCUS: {
                     Sys_SendMessage( OWNER(hwnd), WM_CONTROL, MPFROM2SHORT(Id,CBN_SETFOCUS), 0 ) ;
                     break; }
                  case LN_KILLFOCUS: {
                     Sys_SendMessage( OWNER(hwnd), WM_CONTROL, MPFROM2SHORT(Id,CBN_KILLFOCUS), 0 ) ;
                     break; }
               } /* endswitch */
               break; }
         } /* endswitch */
         break; }

      case WM_MEASUREITEM:
         return ( Sys_SendMessage( OWNER(hwnd), msg, mp1, mp2 ) ) ;

      case WM_DRAWITEM: 
         return ( Sys_SendMessage( OWNER(hwnd), msg, mp1, mp2 ) ) ;

   } /* endswitch */

   return ( DefaultProcessor ? DefaultProcessor ( hwnd, msg, mp1, mp2 ) : 0 ) ;
}
示例#4
0
VOID _Optlink fntMoveThread(PTHREADINFO pti)
{
    // give ourselves higher priority...
    // otherwise we can't compete with Netscape and Win-OS/2 windows.
    DosSetPriority(PRTYS_THREAD,
                   PRTYC_REGULAR,
                   PRTYD_MAXIMUM,
                   0);      // current thread

    if (    (G_pHookData->hwndPagerMoveThread = WinCreateWindow(HWND_OBJECT,
                                                                 WC_STATIC,
                                                                 "",
                                                                 0,
                                                                 0, 0, 0, 0,
                                                                 0,
                                                                 HWND_BOTTOM,
                                                                 0,
                                                                 NULL,
                                                                 NULL))
         && (G_pfnwpMoveStaticOrig = WinSubclassWindow(G_pHookData->hwndPagerMoveThread,
                                                       fnwpMoveThread))
       )
    {
        QMSG qmsg;
        while (WinGetMsg(pti->hab, &qmsg, NULLHANDLE, 0, 0))
            WinDispatchMsg(pti->hab, &qmsg);
    }

    // destroy the object window V0.9.12 (2001-05-12) [umoeller]
    WinDestroyWindow(G_pHookData->hwndPagerMoveThread);
    G_pHookData->hwndPagerMoveThread = NULLHANDLE;
}
示例#5
0
/*----------------------------------------------------------------------*/
BOOL EXPENTRY DMLBInitialize(HWND LBHwnd, HMODULE ResourceHMod)
/*----------------------------------------------------------------------*/
/* Setup direct-manipulation capabilites on given listbox.  This        */
/* function takes care of creating the instance data needed by the      */
/* subclass procedure, and subclassing the listbox window.  This is     */
/* the only external API for DMLB.                                      */
/*----------------------------------------------------------------------*/
{
DMLBData *InstData;

  /* Create and initialize listbox instance data.  Note that we use */
  /* the listbox window words for a ptr to our instance data.  We   */
  /* preserve the current value of the window words in the first    */
  /* PVOID of our instance data where the app can use it.           */

  InstData = malloc(sizeof(DMLBData));
  memset(InstData, 0x00, sizeof(DMLBData));
  InstData->AppData      = WinQueryWindowPtr(LBHwnd, QWL_USER);
  InstData->TargetHwnd   = LBHwnd;         // Inital target is self
  InstData->TargetDropMode= DROPMODE_MOVE; // Default drop mode is MOVE
  InstData->ResHMod      = ResourceHMod;   // Module to load ptr resources

  /* Note: must set this before subclassing since the subclass */
  /* proc assumes it is set.                                   */

  WinSetWindowPtr(LBHwnd, QWL_USER, InstData);
  InstData->OldProcAddr = WinSubclassWindow(LBHwnd, (PFNWP)DMLBSubclassListboxProc);
  if (InstData->OldProcAddr == NULL) {
    free(InstData);
    return FALSE;
  }
  return TRUE;
}
示例#6
0
文件: kimehook.c 项目: komh/kime
BOOL EXPENTRY installHook( HAB habAB, PHOOKDATA phd )
{
    if( DosQueryModuleHandle( DLL_NAME, &hm ) != 0 )
        return FALSE;

    IM32Init();

    hab = habAB;
    WinSetHook( hab, NULLHANDLE, HK_INPUT, ( PFN )inputHook, hm );
    WinSetHook( hab, NULLHANDLE, HK_ACCEL, ( PFN )accelHook, hm );
    WinSetHook( hab, NULLHANDLE, HK_SENDMSG, ( PFN )sendMsgHook, hm );
    WinSetHook( hab, NULLHANDLE, HK_DESTROYWINDOW, (PFN)destroyWindowHook, hm );

    hwndKime = phd->hwndKime;
    hwndHIA = phd->hwndHIA;
    hwndIB = phd->hwndIB;
    hwndKHS = phd->hwndKHS;

    hwndCurrentInput = NULLHANDLE;

    oldKimeWndProc = WinSubclassWindow( hwndKime, newKimeWndProc );

    WinSendMsg( hwndHIA, HIAM_SETHANJAKEYCHECKPROC, MPFROMP( isHanjaKey ), 0 );
    WinSendMsg( hwndHIA, HIAM_SETSPECIALCHARKEYCHECKPROC, MPFROMP( isSpecialCharKey ), 0 );

    return TRUE;
}
MRESULT EXPENTRY MyWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  SWP   swp;
  ULONG rc;

  HWND  hFrame;
  HWND  hListBox;                                /* Listbox window handle    */

  switch (msg)
         {
         case WM_CREATE:
              hListBox = WinCreateWindow(hwnd,
                                         WC_LISTBOX,
                                         NULL,
                                         WS_VISIBLE     |
                                         LS_NOADJUSTPOS |
                                         LS_HORZSCROLL,
                                         0, 0, 0, 0,
                                         hwnd,
                                         HWND_TOP,
                                         ID_LISTBOX,
                                         0,
                                         0);

              pwpList = WinSubclassWindow(hListBox,
                           wpSubList);

              hFrame = WinQueryWindow(hwnd,
                                      QW_PARENT);
              rc = WinSetWindowPos(hFrame,
                                   HWND_TOP,
                                   0, 0,
                                   400, 300,
                                   SWP_SIZE     |
                                   SWP_ACTIVATE |
                                   SWP_SHOW);
              break;

         case WM_SIZE:
              WinQueryWindowPos(hwnd, &swp);
              hListBox=WinWindowFromID(hwnd,
                                       ID_LISTBOX);
              WinSetWindowPos(hListBox,
                              HWND_TOP,
                              swp.x, swp.y,
                              swp.cx, swp.cy,
                              SWP_SIZE  |
                              SWP_SHOW);
              break;

         default:
              return(WinDefWindowProc(hwnd,
                                      msg,
                                      mp1,
                                      mp2));
         }
  return((MRESULT)FALSE);
}
示例#8
0
//-----------------------------------------------------------------------------
// NPP_Destroy:
//-----------------------------------------------------------------------------
NPError NP_LOADDS
NPP_Destroy(NPP instance, NPSavedData** save) {
  if ( instance == 0 ) return NPERR_INVALID_INSTANCE_ERROR;

  PluginInstance* This = (PluginInstance*) instance->pdata;

  //
  // *Developers*: If desired, call NP_MemAlloc to create a
  // NPSavedDate structure containing any state information
  // that you want restored if this plugin instance is later
  // recreated.
  //

  if ( This ) {
    // destroy hmf and PS
    if ( This->hmf ) GpiDeleteMetaFile( This->hmf );
    if ( This->hps ) GpiDestroyPS( This->hps );
    // delete buffer
    if ( This->bufMeta ) {
      free( This->bufMeta );
      This->bufMeta=NULL;
      This->cbMeta=0;
      This->offMeta=0;
    }
    // Remove the subclass for the client window
    if ( This->hWnd ) WinSubclassWindow( This->hWnd, This->lpfnOldWndProc );
    // make some saved instance data if necessary
    if ( This->pSavedInstanceData == 0 ) {
      // make a struct header for the data
      This->pSavedInstanceData =
          (NPSavedData*)NPN_MemAlloc(sizeof (struct _NPSavedData));
      // fill in the struct
      if ( This->pSavedInstanceData != 0 ) {
        This->pSavedInstanceData->len = 0;
        This->pSavedInstanceData->buf = 0;

        // replace the def below and references to it with your data
        #define SIDATA "aSavedInstanceDataBlock"

        // the data
        This->pSavedInstanceData->buf = NPN_MemAlloc(sizeof SIDATA);

        if( This->pSavedInstanceData->buf ) {
          strcpy((char*)This->pSavedInstanceData->buf, SIDATA);
          This->pSavedInstanceData->len = sizeof SIDATA;
        }
      }
    }

    // save some instance data
    *save = This->pSavedInstanceData;

    NPN_MemFree(instance->pdata);
    instance->pdata = 0;
  }
  return NPERR_NO_ERROR;
}
示例#9
0
/*---------------------------------------------------------------------------
                                  CmdMate
---------------------------------------------------------------------------*/
void CmdMate( WNDATTR *wndattr )
{
  if (MateScrollWnd != NULLHANDLE)
     MateScrollWnd = NULLHANDLE;
  else
     OldWndProc = WinSubclassWindow( wndattr->Client, MateWndProc );

  return;
}
示例#10
0
HWND bookSetup( ULONG idInitialPage )
{
    HWND hwndFrame;

    if( hwndBook )
    {
        hwndFrame = PARENT( hwndBook );

        // For some reason it is necessary to restore the notebook before
        // setting the frame as the active window if the frame is being
        // restored from a minimized state.

        WinSetWindowPos( hwndBook, NULLHANDLE, 0, 0, 0, 0,
                         SWP_SHOW | SWP_RESTORE );
        WinSetWindowPos( hwndFrame, NULLHANDLE, 0, 0, 0, 0,
                         SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE );
    }
    else
    {
        FRAMECDATA fcdata;

        memset( &fcdata, 0, sizeof fcdata );
        fcdata.cb            = sizeof( FRAMECDATA );
        fcdata.flCreateFlags = FRAME_FLAGS;
        fcdata.idResources   = ID_NBFRAME;

        hwndFrame = WinCreateWindow( HWND_DESKTOP, WC_FRAME, NULL, WS_ANIMATE,
                                     0, 0, 0, 0, NULLHANDLE, HWND_TOP,
                                     ID_NBFRAME, &fcdata, NULL );
        if( hwndFrame )
        {
            pfnwpFrame = WinSubclassWindow( hwndFrame, wpNBFrame );
            if( pfnwpFrame )
                if( CreateNotebookWindow( hwndFrame ) )
                    WinSetWindowText( hwndFrame, BOOK_TITLE );
                else
                {
                    WinDestroyWindow( hwndFrame );
                    hwndFrame = NULLHANDLE;
                }
            else
            {
                WinDestroyWindow( hwndFrame );
                Msg( "bookSetup WinSubclassWindow RC(%X)", HWNDERR(hwndFrame) );
                hwndFrame = NULLHANDLE;
            }
        }
        else
            Msg( "bookSetup WinCreateWindow of frame window RC(%X)", HABERR(0));
    }

    if( hwndBook )
        TurnToPage( idInitialPage );

    return hwndFrame;
}
示例#11
0
void toLink( HWND hwnd )
{
    linkData *ld;
    detectBrowser();
    ld = (linkData *)malloc( sizeof( linkData ) );
    memset( ld, 0, sizeof( linkData ) );
    ld->labelProc = WinSubclassWindow( hwnd, LinkLabelProc );
    WinSetWindowULong( hwnd, QWL_USER, (ULONG)ld );
    WinInvalidateRect( hwnd, NULL, FALSE );
}
示例#12
0
TOOLBAR :: Toolbar (HWND hwndFrame)
{
    TOOLBAR::ptb = this; // FIXME puke!

    fHidden = TRUE;
    this->hwndFrame = hwndFrame;

    if (WinWindowFromID (hwndFrame, FID_CLIENT))
        fOwnerIsDialog = FALSE;
    else
        fOwnerIsDialog = TRUE;

    // no buttons by now ...
    c = 0;
    memset (aid, 0x00, sizeof (aid[0]) * TOOLBARBUTTONSMAX);

    if (! (pfnwpOldFrame =
           WinSubclassWindow (hwndFrame, PFNWP (fnwpNewFrame))))
        return;

    // if not already registered, register our window class
    if (! fClassRegistered)
    {
        WinRegisterClass (GETHAB, PSZ_WCTOOLBAR, fnwp, 0L, 4L);
        fClassRegistered = TRUE;
    }

    // either place under menu or under titlebar
    SHORT  y, cx;
    SWP    swp;

    if ((hwndAnchor = WinWindowFromID (hwndFrame, FID_MENU)))
    {
        WinQueryWindowPos (hwndAnchor, &swp);
        cx = swp.cx;
        y  = swp.y-CY_TOOLBAR;
    }
    else if ((hwndAnchor = WinWindowFromID (hwndFrame, FID_TITLEBAR)))
    {
        WinQueryWindowPos (hwndAnchor, &swp);
        cx = swp.cx;
        y  = swp.y-CY_TOOLBAR;
    }
    else
    {
        cx = 1;
        y = 0;
    }

    // create client window and assign object ptr to window word
    hwnd = WinCreateWindow (hwndFrame, PSZ_WCTOOLBAR, "", 0L, 0,y,
                            cx,CY_TOOLBAR, hwndFrame, HWND_TOP, FID_TOOLBAR,
                            NULL, NULL);
    WinSetWindowPtr (hwnd, 0, this);
}
/*--------------------------------------------------
 * Stop handling events
 *-------------------------------------------------*/
PMWindow& PMWindow::stop_handling_events()
{
  if( WinIsWindow( PMGUI::hab(), handle()))
  {
    if( !WinSetWindowPtr( handle(), 0, 0 ))
      PM_THROW_GUIERROR();

    if( WinSubclassWindow( handle(), win_default_handler ) == 0 )
      PM_THROW_GUIERROR();
  }
  return *this;
}
示例#14
0
BOOL createChild(PELBOX pelb, PELBOXCDATA pelbcd) {
   LONG pp[] = {12, PP_BACKGROUNDCOLOR, 4, pelb->lbkgnd};
   if (!(pelb->hlbx = WinCreateWindow(pelb->hwnd, WC_LISTBOX, NULL,
                                  LS_OWNERDRAW | LS_MULTIPLESEL | 
                                  LS_NOADJUSTPOS | WS_VISIBLE,
                                  0, 0, pelb->szllb.cx, pelb->szllb.cy,
                                  pelb->hwnd, HWND_TOP, FID_LIST,
                                  NULL, (PVOID)pp)) ||
       !(pelb->lbxwprc = WinSubclassWindow(pelb->hlbx, newlboxproc)))
      return FALSE;
   return TRUE;
}
示例#15
0
文件: kimehook.c 项目: komh/kime
VOID EXPENTRY uninstallHook( VOID )
{
    WinSubclassWindow( hwndKime, oldKimeWndProc );

    WinReleaseHook( hab, NULLHANDLE, HK_INPUT, ( PFN )inputHook, hm );
    WinReleaseHook( hab, NULLHANDLE, HK_ACCEL, ( PFN )accelHook, hm );
    WinReleaseHook( hab, NULLHANDLE, HK_SENDMSG, ( PFN )sendMsgHook, hm );
    WinReleaseHook( hab, NULLHANDLE, HK_DESTROYWINDOW, (PFN)destroyWindowHook, hm );

    WinBroadcastMsg(HWND_DESKTOP, WM_NULL, 0, 0, BMSG_FRAMEONLY | BMSG_POST);

    IM32Term();
}
示例#16
0
int EDITAPI EDITConnect( void )
/**************************************/
{
    ULONG       style = 0;

    if( hwndDDE != NULLHANDLE ) return( TRUE );
    hwndDDE = WinCreateStdWindow( HWND_DESKTOP, 0, &style, WC_FRAME,
                                  NULL, 0, NULLHANDLE, 0, NULL );
    if( hwndDDE == NULLHANDLE ) {
        return( FALSE );
    }
    prevClientProc = WinSubclassWindow( hwndDDE, (PFNWP)clientProc );
    return( TRUE );
}
/*--------------------------------------------------
 * Handle events
 *-------------------------------------------------*/
PMWindow& PMWindow::handle_events()
{
  if( !win_default_handler )
  {
    win_default_handler = WinSubclassWindow( handle(), PMWindow::win_proc );

    if( !win_default_handler )
      PM_THROW_GUIERROR();

    if( !WinSetWindowPtr( handle(), 0, this ))
      PM_THROW_GUIERROR();
  }
  return *this;
}
示例#18
0
文件: kva_wo.c 项目: komh/kva
static APIRET APIENTRY woDone( VOID )
{
    ULONG rc;

    free( m_hwvc.fccColorType );

    WinSubclassWindow( m_hwndKVA, m_pfnwpOld );

    rc = m_pfnHWVIDEOClose();

    DosFreeModule( m_HWVideoHandle );

    return rc;
}
/**********************************************************************
* InitAlarm
*
************************************************************************/
void InitAlarm(HWND hwnd)
{
   USHORT usItem;
   MPARAM Message;

   WinSendMsg(WinWindowFromID(hwnd,
              SCROLL_HOURS),
              SBM_SETSCROLLBAR,
              MPFROMLONG(2),
              MPFROM2SHORT(1, 3));
   WinSendMsg(WinWindowFromID(hwnd,SCROLL_MINUTES),
              SBM_SETSCROLLBAR,
              MPFROMLONG(2),
              MPFROM2SHORT(1, 3));
   WinSendDlgItemMsg(hwnd,
                     IDC_HOURMINUTES,
                     EM_SETTEXTLIMIT,
                     MPFROMLONG(5),
                     MPVOID);
   SetAlarmField(hwnd, cp.alarm.uchHour, cp.alarm.uchMinutes);
   WinSendDlgItemMsg(hwnd,
                     IDC_HOURMINUTES,
                     EM_SETSEL,
                     MPFROM2SHORT(0, 0),
                     MPVOID);
   pfnwpEntryField = WinSubclassWindow(WinWindowFromID(hwnd,
                                                       IDC_HOURMINUTES),
                                                       EntryFieldSubProc);
   usItem = (USHORT)(cp.alarm.usMode & AM_ACTIVE ? RB_ALARMON : RB_ALARMOFF);
   WinSendDlgItemMsg(hwnd,
                     usItem,
                     BM_SETCHECK,
                     MPFROMLONG(1),
                     MPVOID);
   Message = (cp.alarm.usMode & AM_AUDIO)? MPFROMLONG(1) : MPFROMLONG(0);
   WinSendDlgItemMsg(hwnd,
                      IDC_BEEP,
                      BM_SETCHECK,
                      Message,
                      MPVOID);

   Message = (cp.alarm.usMode & AM_MSGBOX) ? MPFROMLONG(1) : MPFROMLONG(0);
   WinSendDlgItemMsg(hwnd,
                     IDC_MSG,
                     BM_SETCHECK,
                     Message,
                     MPVOID);
}
示例#20
0
WEXPORT WClient::WClient( WObject *owner, cbc notify )
        : _owner( owner )
        , _notify( notify )
        , _connected( false )
        , _prevClientProc( NULL )
        , _serverWindow( NULLHANDLE ) {
/*************************************/

    ULONG       style = 0;

    _clientWindow = WinCreateStdWindow( HWND_DESKTOP, 0, &style, WC_FRAME,
                                        NULL, 0, NULLHANDLE, 0, NULL );
    if( _clientWindow != NULLHANDLE ) {
        _prevClientProc = WinSubclassWindow( _clientWindow, (PFNWP)clientWindowProc );
        WinSetWindowPtr( _clientWindow, 0, this );
    }
}
/**************************************************************************
 *
 *  Name       : InitMainWindow()
 *
 *  Description: Creates the application window and puts it into
 *               its initial state.
 *
 *  Concepts   : Called once by the Init() routine
 *               - create main application window
 *               - detach scrollbars from window
 *               - subclass frame window procedure
 *
 *  API's      :  WinCreateStdWindow
 *                WinWindowFromID
 *                WinSetParent
 *                WinSendMsg
 *                WinRegisterClass
 *                WinSubclassWindow
 *
 *  Parameters :  [none]
 *
 *  Return     :  TRUE - window successfully created
 *                FALSE - window creation failed
 *
 *************************************************************************/
BOOL InitMainWindow(VOID)
{
   ULONG ctlData = FCF_STANDARD | FCF_VERTSCROLL | FCF_HORZSCROLL;

   /*
    * Create a window with standard controls.
    */
   vhwndFrame = WinCreateStdWindow(
                         HWND_DESKTOP,
                         WS_VISIBLE,
                         (PULONG)&ctlData,
                         (PSZ)szAppName,
                         (PSZ)NULL,
                         WS_VISIBLE,
                         (HMODULE)NULL,
                         IDR_MAIN,
                         (PHWND)&vhwndClient);
   if (!vhwndFrame)
      return FALSE;

   /*
    * for the time being detach the scrollbars from the main
    * window - but remember their handles for later
    */
   vhwndVScroll = WinWindowFromID(vhwndFrame, FID_VERTSCROLL);
   vhwndHScroll = WinWindowFromID(vhwndFrame, FID_HORZSCROLL);
   WinSetParent(vhwndVScroll, HWND_OBJECT, FALSE);
   WinSetParent(vhwndHScroll, HWND_OBJECT, FALSE);
   WinSendMsg(vhwndFrame, WM_UPDATEFRAME,
              MPFROMLONG(FCF_VERTSCROLL | FCF_HORZSCROLL), (MPARAM)NULL);

   /* save menubar handle */
   vhwndMenu = WinWindowFromID(vhwndFrame, FID_MENU);

   /*
    * the frame window procedure is subclassed, so that frame-sizing
    * restrictions can be implemented.
    */
   if (!WinRegisterClass(vhab, "SUBFRAME", (PFNWP)FrameWndProc, 0L, 0))
      return FALSE;

   vpfnwpFrame = WinSubclassWindow(vhwndFrame, (PFNWP)FrameWndProc);

   return TRUE;
} /* End of InitMainWindow() */
示例#22
0
/*---------------------------------------------------------------------------
                                MateWndProc
---------------------------------------------------------------------------*/
MRESULT EXPENTRY MateWndProc( HWND wnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
 WNDATTR *wndattr;

   switch (msg) {
     case WM_FOCUSCHANGE:
        if (SHORT1FROMMP( mp2 ) == FALSE) {
           wndattr = (WNDATTR*)WinQueryWindowPtr( wnd, QWL_USER );
           MateScrollWnd = HWNDFROMMP( mp1 );
           WinSubclassWindow( wndattr->Client, OldWndProc );
        }
        break;
     default:
        break;
   }

  return OldWndProc( wnd, msg, mp1, mp2 );
}
static INT SetUpControllerHandoffValueSet (HWND hwndDlg)
{
    HWND    hwndVS = WinWindowFromID (hwndDlg, IDVS_CONTROLLERS);
    SHORT   Col;
    HPOINTER    hptrController;

    hptrController = WinLoadPointer (HWND_DESKTOP, 0, IDICON_CONTROLLER);

    for (Col = 1; Col <= 2; ++Col)
    {
        WinSendMsg (hwndVS, VM_SETITEMATTR, MPFROM2SHORT (1, Col),
            MPFROM2SHORT (VIA_DROPONABLE, TRUE));
        WinSendMsg (hwndVS, VM_SETITEM, MPFROM2SHORT (1, Col),
            MPFROMP (hptrController));
    }

    pfnwpValueSet =
        WinSubclassWindow (hwndVS, ControllerValueSetSubclassWndProc);

    return 0;
}
示例#24
0
launchPad::launchPad(HWND hwndParent,HWND hwndOwner, BOOL bVisible, WPFolder *wpParent, LPList** lpadList, HWND hwndPrev, ULONG ulFl)
{
  LPList *lplTemp;

  wpParentFolder=wpParent;
  hwndPrevious=hwndPrev;
  fl=ulFl;
  lpList=lpadList;

  /* Reset text */
  chrFlyOverText[0]=0;

  if((hwndLaunchPad=WinCreateWindow(hwndParent ,WC_FRAME, "Toolbar", FS_BORDER| (bVisible ? WS_VISIBLE: 0),
                                    0, 0, 0, 0, hwndOwner, HWND_TOP, 1234, NULLHANDLE, NULLHANDLE))!=NULLHANDLE) {
    WinSetWindowULong(hwndLaunchPad, QWL_USER,(ULONG) this);//Save object ptr.	
    pfnwpOldLPProc=WinSubclassWindow(hwndLaunchPad, launchPadWindowProc);
  }

  ulNumObjects=0;
  lpoObjectList=NULL;

  /* Add this pad to the list of pads */
  if(!lplAllLPads) {
    /* It's the first one */
    if((lplAllLPads=new LPList)!=NULL) {
      lplAllLPads->lpPad=this;
      lplAllLPads->lplNext=NULL;
    }
  }
  else {
    if((lplTemp=new LPList)!=NULL) {
      lplTemp->lpPad=this;
      lplTemp->lplNext=lplAllLPads;
      lplAllLPads=lplTemp;
    }
  }
}
示例#25
0
MRESULT EXPENTRY OS2Factory::OS2Proc( HWND hwnd, ULONG msg,
                                      MPARAM mp1, MPARAM mp2 )
{
    // Get pointer to thread info: should only work with the parent window
    intf_thread_t *p_intf = (intf_thread_t *)WinQueryWindowPtr( hwnd, 0 );

    // If doesn't exist, treat windows message normally
    if( p_intf == NULL || p_intf->p_sys->p_osFactory == NULL )
    {
        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    }

    OS2Factory *pFactory = (OS2Factory*)OS2Factory::instance( p_intf );
    GenericWindow *pWin = pFactory->m_windowMap[hwnd];

    // Subclass a frame window
    if( !pFactory->m_pfnwpOldFrameProc )
    {
        // Store with it a pointer to the interface thread
        WinSetWindowPtr( pFactory->m_hParentWindow, 0, p_intf );

        pFactory->m_pfnwpOldFrameProc =
            WinSubclassWindow( pFactory->m_hParentWindow, OS2FrameProc );
    }

    if( hwnd != pFactory->getParentWindow() && pWin )
    {
        OS2Loop* pLoop =
            (OS2Loop*) OSFactory::instance( p_intf )->getOSLoop();
        if( pLoop )
            return pLoop->processEvent( hwnd, msg, mp1, mp2 );
    }

    // If hwnd does not match any window or message not processed
    return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}
示例#26
0
static MRESULT EXPENTRY launchPadWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 
{
  WPFolder* thisPtr;
  launchPad * lp;
  LPObject *lpo;
  static USHORT id=0;//Initialisation new in V1.00a 

  switch(msg)
    {
#if 0
    case DM_ENDCONVERSATION:
    case DM_DRAGFILECOMPLETE:
    case DM_DROPNOTIFY:
    case DM_FILERENDERED:
    case DM_RENDERCOMPLETE:

break;
      return (MRESULT)FALSE;
    case WM_ENDDRAG:

      break;
      return (MRESULT)TRUE;
#endif
    case WM_PAINT:
      {
      RECTL rcl;
      launchPad * lp;

      HPS hps=WinBeginPaint(hwnd,NULLHANDLE, &rcl);
      WinFillRect(hps, &rcl, SYSCLR_DIALOGBACKGROUND);
      lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
      if(lp) {
        if(lp->lpQueryNumObjects()==0) {
          WinQueryWindowRect(hwnd,&rcl);
          WinDrawBorder(hps,&rcl,1,1,SYSCLR_WINDOWFRAME,SYSCLR_DIALOGBACKGROUND, DB_STANDARD);
        }
      }
      WinEndPaint(hps);
      return (MRESULT) 0;
      }
    case DM_DRAGOVER:
      return handleDragOver(hwnd, mp1, mp2);
    case DM_DROP:
      {
        ULONG ulCount;
        ULONG ulNumberOfObjects;
        PDRAGITEM pDragItem;
        SOMClass *folderClass;
        WPObject * wpObject;
        PDRAGINFO pDragInfo;
       
        TRY_LOUD(LP_FRAMEDROP) { 
          /* A new object dropped on the launchpad */
          pDragInfo=(PDRAGINFO)mp1;
          if(DrgAccessDraginfo(pDragInfo)) {
            /* Get number of items */
            ulNumberOfObjects = DrgQueryDragitemCount( pDragInfo);           
            if(ulNumberOfObjects>1){
              /* Free the draginfo */
              DrgDeleteDraginfoStrHandles(pDragInfo);
              DrgFreeDraginfo(pDragInfo);
            }
            else { 
              ulCount=0;
              
              pDragItem=DrgQueryDragitemPtr( pDragInfo, ulCount);
              wpObject=(WPObject*)OBJECT_FROM_PREC(DrgQueryDragitemPtr( pDragInfo, ulCount)->ulItemID);
              lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
              if(lp) {
                if(somIsObj(wpObject)) {
  
                  POINTL ptl;
                  int numB;
                  SWP swp;
                  
                  WinQueryWindowPos(hwnd,&swp);
                  ptl.x=pDragInfo->xDrop;
                  ptl.y=pDragInfo->yDrop;
                  /* Pos in window coords */
                  WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
                  numB=(ptl.x-xButtonOffset)/(swp.cy+xButtonDelta);
                  numB=((ptl.x-numB*swp.cy) > swp.cy/2 ? numB+1: numB);

                  /* Do a link */
                  lp->lpAddButton(wpObject, numB);
                  handleDragLeave(hwnd, mp1, mp2);
                }
              }
              DrgDeleteDraginfoStrHandles(pDragInfo);
              DrgFreeDraginfo(pDragInfo);
            }
          }
          handleDragLeave(hwnd, mp1, mp2);
        }
        CATCH(LP_FRAMEDROP)
          {
          } END_CATCH;
          
          break;
      }
    case DM_DRAGLEAVE:
      return handleDragLeave(hwnd, mp1, mp2);
      break;
    case WM_COMMAND:
      if(SHORT1FROMMP(mp2)==CMDSRC_PUSHBUTTON) {
        /* It's a push button */
        lpo=(LPObject*)WinQueryWindowULong(WinWindowFromID(hwnd,SHORT1FROMMP(mp1)),QWL_USER);
        if(lpo) {
          if(somIsObj(lpo->wpObject))
            lpo->wpObject->wpViewObject(NULLHANDLE, OPEN_DEFAULT,0);
        }
      }
      return (MRESULT)FALSE;
      /***********************************************/
      /* Stuff for fly over help                     */ 
    case WM_MOUSEMOVE:
      launchPad * lp;

      lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
      if(lp) {
        if(lp->lpQueryNumObjects()!=0) {
          break;
        }
      }
      
#if 0
      tempID=WinQueryWindowUShort(hwnd,QWS_ID);/*  get the id of the window under the pointer  */  			
      if(id!=tempID) {	// New Button?	
        WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay
        id=tempID;  // Save ID 
      }
      else {
        if(!hwndBubbleWindow)
          WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay	
      }
#endif
      if(!hwndBubbleWindow)
        WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 2,(ULONG)iTBFlyOverDelay); // New timer for delay	

      break;
    case WM_DESTROY:
      WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1);//Stop timer if running
      if(hwndBubbleWindow)
        WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
      hwndBubbleWindow=0;
      /* Stop delay timer if running */
      WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd, 2);			
      break;

    case WM_NEWBUBBLE:
      ULONG bubbleEnabled;
      HWND hwndStore;
      POINTL ptl;
      RECTL  rclWork;
      LONG  ulWinTextLen;
      POINTL aptlPoints[TXTBOX_COUNT];
      LONG   deltaX,deltaY;
      HPS  hps;
      RECTL   rcl;
  
      /*  we have to build a new information window  */
      if(hwndBubbleWindow){// if(){...} new in V1.00a 
        WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
        hwndBubbleWindow=NULL;
      }
      // Query the pointer position
      WinQueryPointerPos(HWND_DESKTOP,&ptl);
      WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
      WinQueryWindowRect(hwnd,&rclWork);				
      if(!hwndBubbleWindow 
         && WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl)
         && bTBFlyOverEnabled) {
        
        static HWND hwndBubbleClient;
        ULONG style=FCF_BORDER|FCF_NOBYTEALIGN;
        char winText[255];
        
        /* Get window text for size calculating */
            lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
        if(lp) {
          strncpy(winText, lp->lpQueryFlyOverText(), sizeof(winText));
          winText[sizeof(winText)-1]=0;
        }

        ulWinTextLen=(LONG)strlen(winText); // Query text length
        
        /* Delete 'Returns' in object title */
        char *pBuchst;
        char *pRest;
        pRest=winText;
        while((pBuchst=strchr(pRest,13))!=NULL) {
          *pBuchst=' ';
          pBuchst++;
          if(*pBuchst==10)
            *pBuchst=' ';
          pRest=pBuchst;
        }
        
        /* Create help window */
        hwndBubbleWindow=WinCreateStdWindow(HWND_DESKTOP,
                                            0,
                                            &style,
                                            WC_STATIC,
                                            "",
                                            SS_TEXT|DT_CENTER|DT_VCENTER,
                                            NULLHANDLE,
                                            400,
                                            &hwndBubbleClient);

        hwndShadow=WinCreateWindow(HWND_DESKTOP,
                                   WC_STATIC,
                                   "",
                                   SS_TEXT|DT_CENTER|DT_VCENTER,
                                   0, 0,
                                   0, 0,
                                   hwndBubbleWindow,
                                   hwndBubbleWindow,
                                   401,
                                   NULLHANDLE,
                                   NULLHANDLE);
        oldProc=WinSubclassWindow(hwndShadow, shadowProc);

        // Set the font for the help
        WinSetPresParam(hwndBubbleClient,PP_FONTNAMESIZE,
                        sizeof(chrTBFlyFontName),
                        chrTBFlyFontName);
        /* Calculate text size in pixel */
        hps=WinBeginPaint(hwndBubbleClient,(HPS)NULL,(PRECTL)NULL);
        GpiQueryTextBox(hps,ulWinTextLen,winText,TXTBOX_COUNT,aptlPoints);
        WinEndPaint(hps);
        
        /* Set colors */
        WinSetPresParam(hwndBubbleClient,
                        PP_BACKGROUNDCOLOR,sizeof(rgbTBFlyBackground) ,
                        &rgbTBFlyBackground );
        WinSetPresParam(hwndBubbleClient,
                        PP_FOREGROUNDCOLOR,sizeof(rgbTBFlyForeground) ,
                        &rgbTBFlyForeground );
        
        /* Calculate bubble positon and show bubble */
        WinQueryPointerPos(HWND_DESKTOP,&ptl);//Query pointer position in the desktop window
        WinQueryWindowRect(HWND_DESKTOP,&rcl);//Query desktop size
        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+7+xVal+ptl.x 
          > rcl.xRight 
          ? deltaX=-aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x-xVal-xVal-7 
	      : deltaX=0 ;
        
        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2+yVal+ptl.y 
          > rcl.yTop 
          ? deltaY=-aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y-2*yVal-7
	      : deltaY=0 ;		
        WinSetWindowPos(hwndBubbleWindow,
                        HWND_TOP,
                        ptl.x+xVal+deltaX,ptl.y+yVal+deltaY,  
                        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
                        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
                        SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);

        WinSetWindowPos(hwndShadow,
                        hwndBubbleWindow,
                        ptl.x+xVal+deltaX+5
                        ,ptl.y+yVal+deltaY-5,  
                        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
                        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
                        SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);
        
        /* Set bubble text */
        WinSetWindowText(hwndBubbleClient,winText);
        WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,1,35); 
      } // end if(!hwndBubbleWindow)
      break;
    case WM_TIMER:
      switch (SHORT1FROMMP(mp1))
        {
        case 1: //Intervall timer
          {
            POINTL ptl;
            RECTL  rclWork;

            /* Test pointer position */
            WinQueryPointerPos(HWND_DESKTOP, &ptl);
            WinMapWindowPoints(HWND_DESKTOP, hwnd,&ptl, 1);
            WinQueryWindowRect(hwnd, &rclWork);
            if(!WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
              {	// Window has changed				 
                WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 1);  // stop the running timer
                if(hwndBubbleWindow) 
                  WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
                hwndBubbleWindow=0;
                id=0;
              }			 			
          break;
          }
        case 2:// delay over
          {//our own timer.
            POINTL ptl;
            RECTL  rclWork;

            WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 2);//Stop the delay timer
            /* Check the pointer position */
            WinQueryPointerPos(HWND_DESKTOP,&ptl);
            WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
            WinQueryWindowRect(hwnd,&rclWork);
            if(WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
              WinPostMsg(hwnd,WM_NEWBUBBLE,NULL,NULL);//Request a help window
            return (MRESULT)FALSE;
          }
        default:
          break;
        }
      break;
    default:
      break;    
    }
  return pfnwpOldLPProc(hwnd, msg, mp1, mp2);
}
示例#27
0
BOOL launchPad::lpFillPad()
{
  HOBJECT hObject;
  char chrSetup[CCHMAXPATH];
  WPFolder* wpFolder;
  LPObject *lpoTemp;

  SWP swp;
  HWND hwndTemp;
  BTNCDATA btCtrl;
  WNDPARAMS wndParams;
  ULONG ulStyle;
  int a;
  LONG lXSize;
  HENUM hEnum;
  HWND hwndClient;
  LONG lCxSave;

  /* Remove Buttons from pad */
  lpClearPad();

  /* Resize the pad for all objects */
  if(!WinQueryWindowPos(hwndLaunchPad, &swp))
    return FALSE;


  lCxSave=swp.cx;

  lXSize=(ulNumObjects == 0 ? swp.cy : (ulNumObjects) * (swp.cy+xButtonDelta) +2*xButtonOffset);
  lpSetLaunchPadPos( NULLHANDLE,0,0, lXSize , swp.cy, SWP_SIZE);

  /* Move all controls on the right */
  /* Move all client windows so they keep their distance to the left border */
  hEnum=WinBeginEnumWindows(WinQueryWindow(hwndLaunchPad,QW_PARENT));
  while((hwndClient=WinGetNextWindow(hEnum))!=NULLHANDLE) {
    SWP swpClient;

    WinQueryWindowPos(hwndClient,&swpClient);
    if(swpClient.x > swp.x)
      WinSetWindowPos(hwndClient, NULLHANDLE, swpClient.x+(lXSize-lCxSave), swpClient.y, 0, 0, SWP_MOVE);
  }/* while */
  WinEndEnumWindows(hEnum);

  lpoTemp=lpoObjectList;
  for(a=ulNumObjects;a>0 && lpoTemp; a--)
    {
      /* Create Buttons */ 
      if((hwndTemp=WinCreateWindow(hwndLaunchPad, WC_BUTTON, lpoTemp->chrName, WS_VISIBLE, xButtonOffset+(a-1)*(swp.cy+xButtonDelta), 1, swp.cy-2, swp.cy-2,
                                   hwndLaunchPad, HWND_TOP, a*100,
                                   NULLHANDLE, NULLHANDLE))!=NULLHANDLE)
        {
          /* Change Style to mini icon */
          ulStyle=WinQueryWindowULong(hwndTemp,QWL_STYLE);
          ulStyle|=(BS_MINIICON);
          ulStyle&=~BS_TEXT;
          if(WinSetWindowULong(hwndTemp,QWL_STYLE,ulStyle)) {
            memset(&btCtrl,0,sizeof(btCtrl));
            btCtrl.cb=sizeof(btCtrl);
            btCtrl.hImage=lpoTemp->hPtr;
            memset(&wndParams,0,sizeof(wndParams));
            wndParams.fsStatus=WPM_CTLDATA;
            wndParams.cbCtlData=btCtrl.cb;
            wndParams.pCtlData=&btCtrl;
            WinSendMsg(hwndTemp,WM_SETWINDOWPARAMS,
                       MPFROMP(&wndParams),0);
            /* Subclass button for flyover help */
            oldButtonProc2=WinSubclassWindow(hwndTemp, newLaunchPadButtonProc);
            /* Set the class pointer into the window words */
            WinSetWindowULong(hwndTemp,QWL_USER,(ULONG)lpoTemp);//Save object ptr.
          }
        }
      lpoTemp=lpoTemp->lpoNext;
    }
  return TRUE;  
}
VOID main()
{

  if ( (hab = WinInitialize( 0L )) == (HAB) NULL ){
     printf( "ToolBar Error:  WinInitialize failed \n" );
     return;
  }
  else {
     if ( (hmq = WinCreateMsgQueue( hab, 0 )) == (HMQ) NULL ){
        printf( "ToolBar Error:  WinCreateMsgQueue failed \n" );
        return;
     }
     else {

       ULONG fulCreate= FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
                        FCF_MINMAX | FCF_SHELLPOSITION | FCF_ICON  ;
               /*
                *  Note: no menu was specificed in create flags
                */

        WinSetPointer( HWND_DESKTOP,
                       WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,TRUE));

        WinRegisterClass(hab, szClassName, (PFNWP)MainWindowProc, CS_SIZEREDRAW, 0);

        hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
                                       0L,
                                       (PULONG)&fulCreate,
                                       szClassName ,
                                       szMainTitle,
                                       0L,
                                       (HMODULE)NULL,
                                       ID_MAIN_WIN,
                                       &hwndClient);
        if ( hwndFrame == NULLHANDLE ) {
           ShowErrorWindow( "Error creating Main window !", TRUE );
        }
        else {
           PFNWP     pfnwpOldFrameProc ;

             /* ---------  subclass frame proc  ------------------ */
           pfnwpOldFrameProc = WinSubclassWindow( hwndFrame,
                                                  (PFNWP) NewFrameProc );
           if ( pfnwpOldFrameProc == (PFNWP)0L ){
               ShowErrorWindow( "Error subclassing frame window !", TRUE );
           }
           else {
              PID       pid ;
              SWCNTRL   swCntrl;
              HSWITCH   hSwitch ;
              LONG      lRGB;

                /* -------  store old frame proc with handle  ------- */
              WinSetWindowULong( hwndFrame,
                                 QWL_USER,
                                 (ULONG) pfnwpOldFrameProc );

                /* ------------------ load menus  ------------------- */
              hwndMenuBar = WinLoadMenu( hwndFrame,
                                         (HMODULE)NULL,
                                         MID_MENUBAR );

              hwndToolBar = WinLoadMenu( hwndFrame,
                                         (HMODULE)NULL,
                                         MID_TOOLBAR );
                /*
                 *  Note that the last menu loaded, the toolbar, is the
                 *  one that is associated with the frame as "the" menu.
                 *  this means that hwndMenuBar is the only link to the
                 *  regular action bar, so hang onto it tightly
                 */

                /* ---------- set toolbar background color ---------- */
              lRGB =  WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONDARK, 0L );
              WinSetPresParam( hwndToolBar,
                               PP_BACKGROUNDCOLOR,
                               4L,
                               (PVOID)lRGB );

                /* ---------  set window size and pos  -------------- */
              WinSetWindowPos( hwndFrame,
                               HWND_TOP,
                               0, 0, 370, 300, 
                               SWP_SIZE | SWP_SHOW | SWP_ACTIVATE );

               /* ----------- add program to tasklist  --------------- */
              WinQueryWindowProcess( hwndFrame, &pid, NULL );
              swCntrl.hwnd = hwndFrame ;
              swCntrl.hwndIcon = (HWND) NULL ;
              swCntrl.hprog = (HPROGRAM) NULL ;
              swCntrl.idProcess = pid ;
              swCntrl.idSession = (LONG) NULL ;
              swCntrl.uchVisibility = SWL_VISIBLE ;
              swCntrl.fbJump = SWL_JUMPABLE ;
              sprintf( swCntrl.szSwtitle, szMainTitle );
              hSwitch = WinAddSwitchEntry((PSWCNTRL)&swCntrl);


              WinSetPointer(HWND_DESKTOP,
                            WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE));

                 /* ---------- start the main processing loop ----------- */
              while (WinGetMsg(hab, &qmsg,NULLHANDLE,0,0)){
                  WinDispatchMsg(hab, &qmsg);
              }

              WinRemoveSwitchEntry( hSwitch );
           } /* end of else ( pfnwpOldFrameProc ) */

           WinSetPointer(HWND_DESKTOP,
                         WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE));
           WinDestroyWindow(hwndFrame);
        }  /* end of else (hwndFrame == NULLHANDLE) */

        WinSetPointer(HWND_DESKTOP,
                      WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE));
        WinDestroyMsgQueue(hmq);
     }  /* end of else ( ...WinCreateMsgQueue() */

   WinTerminate(hab);
   }  /* end of else (...WinInitialize(NULL) */
}  /*  end of main() */
static MRESULT EXPENTRY AreaMsgBaseProc(HWND parent, ULONG message, MPARAM mp1, MPARAM mp2)
{
   extern AREALIST arealiste;
   extern HWND hwndhelp;
   static AREADEFLIST *pArea=NULL;
   char pchTemp[LEN_PATHNAME+1];
   SHORT sTemp;

   switch(message)
   {
      case WM_INITDLG:
         pArea=((AREAPAR *)mp2)->pAreaDef;
         WinSubclassWindow(WinWindowFromID(parent, IDD_AS_MSGBASE+9),
                           FileEntryProc);

         WinSendDlgItemMsg(parent, IDD_AS_MSGBASE+9,
                           EM_SETTEXTLIMIT,
                           MPFROMSHORT(LEN_PATHNAME),
                           (MPARAM) NULL);
         if (pArea)
         {
            WinSetDlgItemText(parent, IDD_AS_MSGBASE+9,
                              pArea->areadata.pathfile);

            switch(pArea->areadata.areaformat)
            {
               case AREAFORMAT_FTS:
                  WinCheckButton(parent, IDD_AS_MSGBASE+2, TRUE);
                  break;

               case AREAFORMAT_SQUISH:
                  WinCheckButton(parent, IDD_AS_MSGBASE+3, TRUE);
                  break;

               case AREAFORMAT_JAM:
                  WinCheckButton(parent, IDD_AS_MSGBASE+4, TRUE);
                  break;

               default:
                  WinCheckButton(parent, IDD_AS_MSGBASE+2, TRUE);
                  break;
            }
            switch(pArea->areadata.areatype)
            {
               case AREATYPE_NET:
                  WinCheckButton(parent, IDD_AS_MSGBASE+6, TRUE);
                  break;

               case AREATYPE_ECHO:
                  WinCheckButton(parent, IDD_AS_MSGBASE+7, TRUE);
                  break;

               case AREATYPE_LOCAL:
                  WinCheckButton(parent, IDD_AS_MSGBASE+12, TRUE);
                  break;
            }
            if (pArea->areadata.ulAreaOpt & AREAOPT_FROMCFG)
            {
               WinEnableControl(parent, IDD_AS_MSGBASE+2, FALSE);
               WinEnableControl(parent, IDD_AS_MSGBASE+3, FALSE);
               WinEnableControl(parent, IDD_AS_MSGBASE+4, FALSE);
               WinEnableControl(parent, IDD_AS_MSGBASE+6, FALSE);
               WinEnableControl(parent, IDD_AS_MSGBASE+7, FALSE);
               WinEnableControl(parent, IDD_AS_MSGBASE+12, FALSE);
               WinSendDlgItemMsg(parent, IDD_AS_MSGBASE+9, EM_SETREADONLY,
                                 (MPARAM)TRUE, (MPARAM) NULL);
               WinEnableControl(parent, IDD_AS_MSGBASE+10, FALSE);
            }
         }
         WinDefDlgProc(parent, message, mp1, mp2);
         SetFocusControl(parent, IDD_AS_MSGBASE+9);
         return (MRESULT) TRUE;

      case WM_CLOSE:
      case WM_DESTROY:
         if (!WinQueryWindowULong(parent, QWL_USER))
         {
            WinQueryDlgItemText(parent, IDD_AS_MSGBASE+9, LEN_PATHNAME+1,
                                pchTemp);
            if (strcmp(pArea->areadata.pathfile, pchTemp))
            {
               strcpy(pArea->areadata.pathfile, pchTemp);
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }

            if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+2))
               sTemp=AREAFORMAT_FTS;
            else
               if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+3))
                  sTemp=AREAFORMAT_SQUISH;
               else
                  if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+4))
                     sTemp=AREAFORMAT_JAM;
                  else
                     sTemp=AREAFORMAT_FTS;

            if (sTemp!=pArea->areadata.areaformat)
            {
               pArea->areadata.areaformat=sTemp;
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }

            if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+6))
               sTemp=AREATYPE_NET;
            else
               if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+7))
                  sTemp=AREATYPE_ECHO;
               else
                  if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+12))
                     sTemp=AREATYPE_LOCAL;
                  else
                     sTemp=AREATYPE_NET;

            if (sTemp != pArea->areadata.areatype)
            {
               pArea->areadata.areatype=sTemp;
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }
         }
         break;

      case WM_COMMAND:
         if (SHORT1FROMMP(mp2)==CMDSRC_PUSHBUTTON)
         {
            if(SHORT1FROMMP(mp1)==IDD_AS_MSGBASE+10)
            {
               WinQueryDlgItemText(parent, IDD_AS_MSGBASE+9,
                                   LEN_PATHNAME+1, pchTemp);
               if (GetPathname(parent, pchTemp)==DID_OK)
               {
                  char drive[_MAX_DRIVE];
                  char path[_MAX_DIR];
                  char name[_MAX_FNAME];
                  char ext[_MAX_EXT];

                  _splitpath(pchTemp, drive, path, name, ext);
                  if (WinQueryButtonCheckstate(parent, IDD_AS_MSGBASE+3))
                     _makepath(pchTemp, drive, path, name, "");
                  else
                  {
                    _makepath(pchTemp, drive, path, "", "");
                    pchTemp[strlen(pchTemp)-1]='\0';
                  }
                  WinSetDlgItemText(parent, IDD_AS_MSGBASE+9,
                                    pchTemp);
                  arealiste.bDirty = TRUE;
               }
            }
         }
         return (MRESULT) FALSE;

      case APM_REQCLOSE:
         if (WinQueryDlgItemTextLength(parent, IDD_AS_MSGBASE+9)==0)
         {
            /* Fehler, kein Pfadname */
            if (MessageBox(parent, IDST_MSG_NOPATHFILE, 0,
                           IDD_NOPATHFILE, MB_RETRYCANCEL | MB_ERROR) == MBID_CANCEL)
                return (MRESULT) 2;
            else
                return (MRESULT) 1;
         }
         return (MRESULT) 0;

      case APM_CANCEL:
         WinSetWindowULong(parent, QWL_USER, 1);
         break;

      default:
         break;
   }
   return WinDefDlgProc(parent,message,mp1,mp2);
}
示例#30
0
void Window::createWindow( Window *parent, Window *owner, char *text, 
                           char *windowClass,
                           Window *behind, ULONG windowStyle, int x, int y,
                           int width, int height )
{
  char str[50], *wClass;

  mouseButtonDown = FALSE;

  this->parent = parent;

  if( parent->getType() == DIALOG)
  	behind = (Window *)parent->getLastControl();

  type = WINDOW;
  this->id = Iterator::getNext();

  Application::tempthis = this;

  oldWndProc = NULL;

  if( windowClass == 0L )
  {
    currentPointer = WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE );

		strcpy( str, "KONBASEWINDOW" );
		if( !baseClassRegistered )
		{
			baseClassRegistered = TRUE;
			if( !WinRegisterClass( Application::hab, (PSZ)str, //(PSZ)itoa( id, str, 10),
												WndProc, CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT,
												sizeof(Window *) ) )
			{
				exit( 1 );
			}
		}
    wClass = str;
  }
  else
  {
    currentPointer = NULLHANDLE;
    wClass = windowClass;
  }

	if( windowStyle & WS_DISABLED )
	{
		windowStyle &= ~WS_DISABLED;
		isPopupWin = TRUE;
	}

  hWndFrame = hWndClient = WinCreateWindow( (isPopupWin) ? HWND_DESKTOP : parent->getHWND(), wClass, text,
                                            windowStyle, x, y, width, height,
                                            owner->getHWND(),
                                            (behind == NULL) ? HWND_TOP : behind->getHWND(),
                                            id, 0L, 0L );

  // Subclass window

  if( wClass == windowClass )
  {
    WinSetWindowULong(hWndFrame,0,(ULONG)this);
    oldWndProc = WinSubclassWindow( hWndFrame, (PFNWP)WndProc );
  }

  if( hWndFrame == NULLHANDLE )
  {
    DosBeep( 1000, 100 );
    char wText[501];
    WinQueryWindowText( parent->getHWNDFrame(), 500, wText );
  }

  graphics = new Graphics( WinGetPS( hWndClient ) );
}