コード例 #1
0
ファイル: pmnew.c プロジェクト: ABratovic/open-watcom-v2
/*
 * _NewWindow - create a new window
 */
unsigned _NewWindow( char *name, ... )
{
    LPWDATA     w;
    MENUITEM    menus;
    HWND        hwnd,frame,temp;
    char        str[80];
    int         x1,x2,y1,y2;
    ULONG       style;
    RECTL       rcl;
    va_list     al;

    _GetWindowNameAndCoords( name, str, &x1, &x2, &y1, &y2 );

    style = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX |
            FCF_VERTSCROLL;
    frame = WinCreateStdWindow( _MainWindow,
                WS_VISIBLE | WS_CLIPSIBLINGS,
                &style, _ClassName, str, 0, NULL, 0, &hwnd );
    if( frame == 0 ) return( FALSE );
    WinSetOwner( hwnd, _MainWindow );

    va_start( al, name );
    w = _AnotherWindowData( hwnd, al );
    w->frame = frame;
    w->text_color = CLR_WHITE;
    w->background_color = CLR_BLACK;
    WinSendMsg( frame, WM_SETICON,
        MPFROMLONG( WinQuerySysPointer( HWND_DESKTOP, SPTR_APPICON, TRUE ) ), 0 );
    WinSetWindowBits( WinWindowFromID( w->frame, FID_VERTSCROLL ), QWL_STYLE,
                        SBS_AUTOTRACK, SBS_AUTOTRACK );

    _CreateFont( w );
    _PositionScrollThumb( w );
    WinQueryWindowRect( _MainWindow, &rcl );
    WinSetWindowPos( frame, HWND_TOP,
                x1*w->xchar,
                (rcl.yTop - rcl.yBottom)-y1*w->ychar-y2*w->ychar,
                x2*w->xchar,
                y2*w->ychar,
                SWP_SIZE | SWP_MOVE | SWP_ZORDER );

    menus.iPosition = _MainWindowData->window_count - 1;
    menus.afStyle = MIS_TEXT;
    menus.afAttribute = 0;
    menus.id = DID_WIND_STDIO + w->handles[0];
    menus.hwndSubMenu = NULL;
    menus.hItem = 0;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menuHandle, ( ULONG )MM_INSERTITEM, MPFROMP( &menus ), MPFROMP( str ) ) ) abort();
    temp = WinWindowFromID( frame, FID_SYSMENU );
    WinSendMsg( temp, MM_QUERYITEM, MPFROM2SHORT(SC_SYSMENU, TRUE),
                               MPFROMP((PSZ)&menus) );
    WinSendMsg( menus.hwndSubMenu, MM_DELETEITEM, MPFROM2SHORT( SC_CLOSE, TRUE ), 0 );
    WinUpdateWindow( hwnd );
    WinSetFocus( HWND_DESKTOP, hwnd );
    return( TRUE );

} /* _NewWindow */
コード例 #2
0
ファイル: misc.c プロジェクト: OS2World/UTIL-WPS-CandyFolder
/*
 *   Modified by Chris Wohlgemuth 2001 for use with CandyFolder
 */
BOOL winhAssertWarp4Notebook(HWND hwndDlg,
                    USHORT usIdThreshold,    // in: ID threshold
                    ULONG ulDownUnits)       // in: dialog units or 0
{
    BOOL brc = FALSE;
    POINTL ptl;
    HAB hab = WinQueryAnchorBlock(hwndDlg);
    BOOL    fIsVisible = WinIsWindowVisible(hwndDlg);
    if (ulDownUnits) {
        ptl.x = 0;
        ptl.y = ulDownUnits;
        WinMapDlgPoints(hwndDlg, &ptl, 1, TRUE);
    }

    WinEnableWindowUpdate(hwndDlg, FALSE);

    if (cwQueryOSRelease()>=40) {
        HENUM henum = WinBeginEnumWindows(hwndDlg);
        HWND hwndItem;
        while ((hwndItem = WinGetNextWindow(henum))!=NULLHANDLE) {
            USHORT usId = WinQueryWindowUShort(hwndItem, QWS_ID);

            if (usId <= usIdThreshold) {
                // pushbutton to change:
              WinSetWindowBits(hwndItem, QWL_STYLE,
                        BS_NOTEBOOKBUTTON, BS_NOTEBOOKBUTTON);
                brc = TRUE;
            } else
                // no pushbutton to change: move downwards
                // if desired
                if (ulDownUnits)
                {
                    SWP swp;

                    WinQueryWindowPos(hwndItem, &swp);
                    WinSetWindowPos(hwndItem, 0,
                        swp.x,
                        swp.y - ptl.y,
                        0, 0,
                        SWP_MOVE);
                }
        }
        WinEndEnumWindows(henum);
    }
    if (fIsVisible)
        WinShowWindow(hwndDlg, TRUE);
    return (brc);
}
コード例 #3
0
VOID setEditMode(HWND hwnd, BOOL bEdit) {
   bEditMode = bEdit;
   WinSetWindowBits(DlgItemHwnd(hwnd, EF_CLASSNAME), QWL_STYLE,
                    ES_READONLY * bEdit, ES_READONLY);
   DlgItemEnable(hwnd, LBOX_CLASS, !bEdit);
   showButton(hwnd, BTN_REFRESH, !bEdit, !bEdit);
   showButton(hwnd, BTN_EDIT, !bEdit,
              (!bEdit && (0 <= dLbxItemSelected(hwnd, LBOX_CLASS))));
   showButton(hwnd, BTN_ADD, !bEdit,
              (DlgItemTextLength(hwnd, EF_CLASSNAME)
               && DlgItemTextLength(hwnd, EF_MODULENAME)));
   showButton(hwnd, BTN_DEREG, !bEdit, !bEdit);
   showButton(hwnd, BTN_REMOVE, !bEdit, !bEdit);
   showButton(hwnd, BTN_UPDATE, bEdit, bEdit);
   showButton(hwnd, BTN_CANCEL, bEdit, bEdit);
}
コード例 #4
0
ファイル: clbx.c プロジェクト: OS2World/UTIL-WPS-Styler_2
BOOL clbCreateProc(HWND hwnd, PCLBOXCDATA pclcd, PCREATESTRUCT pc, ULONG style) {
   PCLBOX pclb;
   HPS hps;
   // allocate structure for caching some control data
   if (!(pclb = (PCLBOX)malloc(sizeof(CLBOX)))) return FALSE;
   memset((PVOID)pclb, 0, sizeof(CLBOX));
   // copy some data
   pclb->hab = WinQueryAnchorBlock(hwnd);
   pclb->hwnd = hwnd;
   pclb->fl = pc->flStyle;
   pclb->szl.cx = pc->cx;
   pclb->szl.cy = pc->cy;
   pclb->id = pc->id;
   pclb->hOwner = pc->hwndOwner;
   // Set color control
   if (!(hps = WinGetPS(hwnd))) goto error0;
   clbUpdColors(pclb, hps);
   if ((pclb->cyFont = stSizeFont(hps)) % 2) ++pclb->cyFont;
   WinReleasePS(hps);
   // Interprets controldata
   if (!clbSetCtlData(pclb, pclcd)) goto error0;
   if (clbSetText(pclb, pc->pszText, -1)) *pc->pszText = 0;
   // reset WC_STATIC style
   WinSetWindowBits(hwnd, QWL_STYLE, style, 0xffff);
   WinSetWindowPtr(hwnd, cbWCstc, (PVOID)pclb);
   if (pfnwpWCstc(hwnd, WM_CREATE, (MPARAM)pclcd, (MPARAM)pc)) goto error1;
   // If no CLBXS_CHECK style is set to checkon flags at 1
   if (!(pclb->fl & CLBXS_CHECK)) pclb->is.chkon = 1;
   if (!clbChilds(pclb, pc)) goto error2;
   if (!(pclb->fl & WS_DISABLED)) pclb->is.enbl = 1;
   return TRUE;

   error2:
      WinDestroyWindow(hwnd);
   error1:
      if (pclb->psz) free(pclb->psz);
   error0:
      free(pclb);
      return FALSE;
}
コード例 #5
0
ファイル: pmmain.c プロジェクト: ABratovic/open-watcom-v2
_WCRTLINK int   __InitDefaultWin() {
//==================================

    ULONG       style;
    RECTL       rcl;
    HWND        menhdl;
    HWND        submenu;
    MENUITEM    *menudesc;
    MENUITEM    menus;
    SWP         swp;

    _ClassName = WatcomClass;

    _AnchorBlock = WinInitialize( 0 );
    if( _AnchorBlock == 0 ) return( 0 );
    hMessageQueue = WinCreateMsgQueue( _AnchorBlock, 0 );
    if( hMessageQueue == 0 ) return( 0 );
    if( !WinRegisterClass( _AnchorBlock, _ClassName, (PFNWP)_MainDriver,
                           CS_SIZEREDRAW, 0 ) ) {
        return( 0 );
    }

    _InitMainWindowData( 0 );

    style = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX |
            FCF_SHELLPOSITION | FCF_TASKLIST;
    _MainFrameWindow = WinCreateStdWindow( HWND_DESKTOP,
                        WS_VISIBLE | WS_CLIPCHILDREN,
                        &style, _ClassName, "", 0, NULL, 0, &ClientWindow );

    if( _MainFrameWindow == 0 ) return( 0 );
    WinSendMsg( _MainFrameWindow, WM_SETICON,
        MPFROMLONG( WinQuerySysPointer( HWND_DESKTOP, SPTR_APPICON, TRUE ) ), 0 );
    WinQueryWindowRect( _MainWindow, &rcl );
    WinSetWindowPos( _MainFrameWindow, HWND_TOP,
                rcl.xLeft,
                rcl.yBottom,
                rcl.xLeft - rcl.xRight,
                rcl.yTop - rcl.yBottom,
                SWP_SHOW | SWP_SIZE | SWP_MOVE | SWP_MAXIMIZE );

    _InitFunctionPointers();
    _MainWindow = ClientWindow;
    WinUpdateWindow( _MainWindow );

    menudesc = &menus;
    menhdl = WinCreateMenu( _MainFrameWindow, NULL );
    WinSetWindowBits( menhdl, QWL_STYLE, MS_ACTIONBAR, MS_ACTIONBAR );
    submenu = WinCreateMenu( menhdl, NULL );

    menudesc->afStyle = MIS_TEXT;
    menudesc->afAttribute = 0;
    menudesc->hwndSubMenu = NULL;
    menudesc->hItem = 0;

    menudesc->iPosition = 0;
    menudesc->id = DID_FILE_SAVE;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Save As..." ) ) ) abort();
    menudesc->iPosition = 1;
    menudesc->id = DID_FILE_CLEAR;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Set Lines Between Clears..." ) ) ) abort();
    menudesc->afStyle = MIS_SEPARATOR;
    menudesc->iPosition = 2;
    menudesc->id = 0;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Exit" ) ) ) abort();
    menudesc->afStyle = MIS_TEXT;
    menudesc->iPosition = 3;
    menudesc->id = DID_FILE_EXIT;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Exit" ) ) ) abort();
    menudesc->iPosition = 0;
    menudesc->id = DID_MAIN_FILE;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_TEXT | MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~File" ) ) ) abort();

    submenu = WinCreateMenu( menhdl, NULL );
    menudesc->afStyle = MIS_TEXT;
    menudesc->iPosition = 0;
    menudesc->id = DID_EDIT_CLEAR;
    menudesc->hwndSubMenu = NULL;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Clear" ) ) ) abort();
    menudesc->iPosition = 1;
    menudesc->id = DID_EDIT_COPY;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Copy" ) ) ) abort();
    menudesc->iPosition = 1;
    menudesc->id = DID_MAIN_EDIT;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~Edit" ) ) ) abort();

    submenu = WinCreateMenu( menhdl, NULL );
    _SetWinMenuHandle( submenu );
    menudesc->iPosition = 2;
    menudesc->afAttribute = 0;
    menudesc->id = DID_MAIN_WIND;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~Windows" ) ) ) abort();

    submenu = WinCreateMenu( menhdl, NULL );
    menudesc->afStyle = MIS_TEXT;
    menudesc->iPosition = 0;
    menudesc->id = DID_HELP_ABOUT;
    menudesc->hwndSubMenu = NULL;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "About" ) ) ) abort();
    menudesc->iPosition = 3;
    menudesc->id = DID_MAIN_HELP;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~Help" ) ) ) abort();

    WinSendMsg( _MainFrameWindow, ( ULONG )WM_UPDATEFRAME, 0, 0 );
    _NewWindow( "Standard IO", 0,1,2,-1 );
    WinUpdateWindow( _MainFrameWindow );
    WinQueryWindowPos( _MainWindow, &swp );
    swp.fl |= SWP_MAXIMIZE;
    WinSetWindowPos( _MainWindow, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, SWP_MAXIMIZE | SWP_ACTIVATE | SWP_MOVE | SWP_SHOW | SWP_SIZE );

    return( 1 );
}
コード例 #6
0
MRESULT EXPENTRY fnSaverWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  SWP swpDlg, swpParent;
  HWND hwndDlg;
  int rc;

  switch( msg )
  {
    case WM_SUBCLASS_INIT:
		case WM_CREATE: {
			RECTL rclRect;
			// Any initialization of the window and variables should come here.

			// the timer for the moving text
			ulAnimationTimerID = WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, ANIMATION_TIMER_ID, 20);

			// setup the initial coordinates for the scrolling text
			WinQueryWindowRect(hwnd, &rclRect);
			textX = rclRect.xRight;
			textY = rclRect.yTop/2;

			// Hide mouse pointer, if we're in real screen-saving mode!
			if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE);
			// Initialize WMCHAR record
			internal_InitWMCHARRecord();
		break; }

		case WM_CHAR:
		if (!bOnlyPreviewMode) internal_SaveWMCHAREventToRecord(mp1, mp2);
		break;

    case WM_ASKPASSWORD:
      {
        // Get parameters
        char *pchPwdBuff = (char *) mp1;
	int iPwdBuffSize = (int) mp2;

	// Show mouse pointer, if we're screensaving.
	if (!bOnlyPreviewMode)
	  WinShowPointer(HWND_DESKTOP, TRUE);

	hwndDlg = WinLoadDlg(hwnd, hwnd,
			     fnAutoHiderDlgProc,
			     hmodOurDLLHandle,
			     DLG_PASSWORDPROTECTION,
			     NULL);
	if (!hwndDlg)
	{
	  // Could not load dialog window resources!
	  if (!bOnlyPreviewMode)
	    WinShowPointer(HWND_DESKTOP, FALSE);

	  return (MRESULT) SSMODULE_ERROR_INTERNALERROR;
	}

        // Ok, dialog window loaded!

        // Now set its texts (NLS)
        internal_SetPageFont(hwndDlg);
        internal_SetPwdProtWindowText(hwndDlg);

        // Resize the window so text will fit!
        internal_ArrangePwdProtWindowControls(hwndDlg);

	// Initialize control(s)!
	WinSendDlgItemMsg(hwndDlg, EF_PASSWORD,
			  EM_SETTEXTLIMIT,
			  (MPARAM) (iPwdBuffSize-1),
			  (MPARAM) 0);
	WinSetDlgItemText(hwndDlg, EF_PASSWORD, "");

	// Center dialog in screen
	if (WinQueryWindowPos(hwndDlg, &swpDlg))
	  if (WinQueryWindowPos(hwnd, &swpParent))
	  {
	    // Center dialog box within the screen
	    int ix, iy;
	    ix = swpParent.x + (swpParent.cx - swpDlg.cx)/2;
	    iy = swpParent.y + (swpParent.cy - swpDlg.cy)/2;
	    WinSetWindowPos(hwndDlg, HWND_TOP, ix, iy, 0, 0,
			    SWP_MOVE);
	  }
	WinSetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0,
			SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);

		// Re-send WM_CHAR messages if needed
		if (bFirstKeyGoesToPwdWindow) internal_ReplayWMCHARRecord();

	// Process the dialog!
	rc = WinProcessDlg(hwndDlg);

	if (rc!=PB_OK)
	{
	  // The user pressed cancel!
          rc = SSMODULE_ERROR_USERPRESSEDCANCEL;
	} else
	{
	  // The user pressed OK!
	  // Get the entered password
	  WinQueryDlgItemText(hwndDlg, EF_PASSWORD,
			      iPwdBuffSize,
			      pchPwdBuff);
          rc = SSMODULE_NOERROR;
	}

	// Destroy window
	WinDestroyWindow(hwndDlg);

	// Hide mouse pointer again, if we're screensaving.
	if (!bOnlyPreviewMode)
	  WinShowPointer(HWND_DESKTOP, FALSE);

	return (MRESULT) rc;
      }

    case WM_SHOWWRONGPASSWORD:

      // Show mouse pointer, if we're screensaving.
      if (!bOnlyPreviewMode)
	WinShowPointer(HWND_DESKTOP, TRUE);

      hwndDlg = WinLoadDlg(hwnd, hwnd,
                           fnAutoHiderDlgProc,
                           hmodOurDLLHandle,
                           DLG_WRONGPASSWORD,
                           NULL);
      if (!hwndDlg)
      {
	// Could not load dialog window resources!

	if (!bOnlyPreviewMode)
          WinShowPointer(HWND_DESKTOP, FALSE);

        return (MRESULT) SSMODULE_ERROR_INTERNALERROR;
      }

      // Ok, dialog window loaded!

      // Now set its texts (NLS)
      internal_SetPageFont(hwndDlg);
      internal_SetWrongPwdWindowText(hwndDlg);

      // Resize the window so text will fit!
      internal_ArrangeWrongPwdWindowControls(hwndDlg);

      // Center dialog in screen
      if (WinQueryWindowPos(hwndDlg, &swpDlg))
        if (WinQueryWindowPos(hwnd, &swpParent))
        {
          // Center dialog box within the screen
          int ix, iy;
          ix = swpParent.x + (swpParent.cx - swpDlg.cx)/2;
          iy = swpParent.y + (swpParent.cy - swpDlg.cy)/2;
          WinSetWindowPos(hwndDlg, HWND_TOP, ix, iy, 0, 0,
                          SWP_MOVE);
        }
      WinSetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0,
                      SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);

      // Process the dialog!
      rc = WinProcessDlg(hwndDlg);

      // Destroy window
      WinDestroyWindow(hwndDlg);

      // Hide mouse pointer again, if we're screensaving.
      if (!bOnlyPreviewMode)
        WinShowPointer(HWND_DESKTOP, FALSE);

      return (MRESULT) SSMODULE_NOERROR;

    case WM_SUBCLASS_UNINIT:
    case WM_DESTROY:
      // All kinds of cleanup (the opposite of everything done in WM_CREATE)
      // should come here.


      WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, ulAnimationTimerID);


      // Restore mouse pointer, if we're in real screen-saving mode!
      if (!bOnlyPreviewMode)
        WinShowPointer(HWND_DESKTOP, TRUE);
      break;

    case WM_ADJUSTWINDOWPOS:
      if (!bOnlyPreviewMode)
      {
	SWP *pSWP;

	// The following is required so that this window will be on
        // top of the xCenter window, evenif that is set to be always on top!

	// Real screensaving, here we should stay on top!
        // Set WS_TOPMOST flag again!
	WinSetWindowBits(hwnd, QWL_STYLE, WS_TOPMOST, WS_TOPMOST);

	pSWP = (SWP *) mp1;
	pSWP->hwndInsertBehind = HWND_TOP;
        pSWP->fl |= SWP_ZORDER;
      }
      break;
		case WM_PAINT: {
			HPS hpsBeginPaint;
			RECTL rclRect, blank, rclWindow;
			FONTMETRICS fm;
			int len;

			#ifdef DEBUG_LOGGING
				AddLog("WM_PAINT\n");
			#endif

			hpsBeginPaint = WinBeginPaint(hwnd, NULLHANDLE, &rclRect);
			WinQueryWindowRect(hwnd, &rclRect);
			WinQueryWindowRect(hwnd, &rclWindow);

			WinSetWindowFontMy(hwnd, "10.Courier");	
			GpiQueryFontMetrics(hpsBeginPaint, sizeof(fm), &fm);

			rclRect.xLeft = textX;
			rclRect.yTop  = textY;
			len = strlen(CfgDlgInit.pchText);
			rclRect.xRight = rclRect.xLeft + fm./*lAveCharWidth*/lMaxCharInc * len+5;
			rclRect.yBottom = rclRect.yTop - fm.lMaxBaselineExt;
			WinDrawText(hpsBeginPaint, len ,CfgDlgInit.pchText, &rclRect, CLR_WHITE, CLR_BLACK, DT_ERASERECT | DT_LEFT | DT_VCENTER);
			/* paint the black around the text*/
			blank.xLeft = 0; blank.yBottom = 0; blank.xRight = rclRect.xLeft; blank.yTop = rclWindow.yTop; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK);
			blank.xLeft = rclRect.xLeft-2; blank.yBottom = rclRect.yTop; blank.xRight = rclWindow.xRight; blank.yTop = rclWindow.yTop; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK);
			blank.xLeft = rclRect.xRight; blank.yBottom = 0; blank.xRight = rclWindow.xRight; blank.yTop = rclRect.yTop; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK);
			blank.xLeft = rclRect.xLeft-2; blank.yBottom = 0; blank.xRight = rclRect.xRight+2; blank.yTop = rclRect.yBottom; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK);
			if (rclRect.xRight <= -10) {
				WinQueryWindowRect(hwnd, &rclRect);
				textX = rclRect.xRight;
				textY = rclRect.yTop/2;
			}
			WinEndPaint(hpsBeginPaint);

			#ifdef DEBUG_LOGGING
				AddLog("WM_PAINT done\n");
			#endif
			return (MRESULT) FALSE;
		}

     case WM_TIMER:
      if (((SHORT)mp1)==ANIMATION_TIMER_ID)
      {
	// Timer, so make new image position
	textX -= 2;
	WinInvalidateRect(hwnd, NULL, FALSE);
      }
      break;

    default:
      break;
  }

  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}
コード例 #7
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;
}
コード例 #8
0
MRESULT EXPENTRY fnSaverWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  SWP swpDlg, swpParent;
  HWND hwndDlg;
  int rc;

  switch( msg )
  {
    case WM_SUBCLASS_INIT:
    case WM_CREATE:
      // Any initialization of the window and variables should come here.

      // Hide mouse pointer, if we're in real screen-saving mode!
      if (!bOnlyPreviewMode)
        WinShowPointer(HWND_DESKTOP, FALSE);
      // Initialize WMCHAR record
      internal_InitWMCHARRecord();
      break;

    case WM_CHAR:
      if (!bOnlyPreviewMode)
        internal_SaveWMCHAREventToRecord(mp1, mp2);
      break;

    case WM_ASKPASSWORD:
      {
        // Get parameters
        char *pchPwdBuff = (char *) mp1;
	int iPwdBuffSize = (int) mp2;

	// Show mouse pointer, if we're screensaving.
        if (!bOnlyPreviewMode)
          WinShowPointer(HWND_DESKTOP, TRUE);

	hwndDlg = WinLoadDlg(hwnd, hwnd,
			     fnAutoHiderDlgProc,
			     hmodOurDLLHandle,
			     DLG_PASSWORDPROTECTION,
			     NULL);
	if (!hwndDlg)
	{
	  // Could not load dialog window resources!
          if (!bOnlyPreviewMode)
            WinShowPointer(HWND_DESKTOP, FALSE);

	  return (MRESULT) SSMODULE_ERROR_INTERNALERROR;
	}

        // Ok, dialog window loaded!

        // Now set its texts (NLS)
        internal_SetPageFont(hwndDlg);
        internal_SetPwdProtWindowText(hwndDlg);

        // Resize the window so text will fit!
        internal_ArrangePwdProtWindowControls(hwndDlg);

	// Initialize control(s)!
	WinSendDlgItemMsg(hwndDlg, EF_PASSWORD,
			  EM_SETTEXTLIMIT,
			  (MPARAM) (iPwdBuffSize-1),
			  (MPARAM) 0);
	WinSetDlgItemText(hwndDlg, EF_PASSWORD, "");

	// Center dialog in screen
	if (WinQueryWindowPos(hwndDlg, &swpDlg))
	  if (WinQueryWindowPos(hwnd, &swpParent))
	  {
	    // Center dialog box within the screen
	    int ix, iy;
	    ix = swpParent.x + (swpParent.cx - swpDlg.cx)/2;
	    iy = swpParent.y + (swpParent.cy - swpDlg.cy)/2;
	    WinSetWindowPos(hwndDlg, HWND_TOP, ix, iy, 0, 0,
			    SWP_MOVE);
	  }
	WinSetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0,
			SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);

        // Re-send WM_CHAR messages if needed
        if (bFirstKeyGoesToPwdWindow)
          internal_ReplayWMCHARRecord();

        // Process the dialog!
	rc = WinProcessDlg(hwndDlg);

	if (rc!=PB_OK)
	{
	  // The user pressed cancel!
          rc = SSMODULE_ERROR_USERPRESSEDCANCEL;
	} else
	{
	  // The user pressed OK!
	  // Get the entered password
	  WinQueryDlgItemText(hwndDlg, EF_PASSWORD,
			      iPwdBuffSize,
			      pchPwdBuff);
          rc = SSMODULE_NOERROR;
	}

	// Destroy window
	WinDestroyWindow(hwndDlg);

	// Hide mouse pointer again, if we're screensaving.
        if (!bOnlyPreviewMode)
          WinShowPointer(HWND_DESKTOP, FALSE);

	return (MRESULT) rc;
      }

    case WM_SHOWWRONGPASSWORD:

      // Show mouse pointer, if we're screensaving.
      if (!bOnlyPreviewMode)
	WinShowPointer(HWND_DESKTOP, TRUE);

      hwndDlg = WinLoadDlg(hwnd, hwnd,
                           fnAutoHiderDlgProc,
                           hmodOurDLLHandle,
                           DLG_WRONGPASSWORD,
                           NULL);
      if (!hwndDlg)
      {
	// Could not load dialog window resources!

        if (!bOnlyPreviewMode)
          WinShowPointer(HWND_DESKTOP, FALSE);

        return (MRESULT) SSMODULE_ERROR_INTERNALERROR;
      }

      // Ok, dialog window loaded!

      // Now set its texts (NLS)
      internal_SetPageFont(hwndDlg);
      internal_SetWrongPwdWindowText(hwndDlg);

      // Resize the window so text will fit!
      internal_ArrangeWrongPwdWindowControls(hwndDlg);

      // Center dialog in screen
      if (WinQueryWindowPos(hwndDlg, &swpDlg))
        if (WinQueryWindowPos(hwnd, &swpParent))
        {
          // Center dialog box within the screen
          int ix, iy;
          ix = swpParent.x + (swpParent.cx - swpDlg.cx)/2;
          iy = swpParent.y + (swpParent.cy - swpDlg.cy)/2;
          WinSetWindowPos(hwndDlg, HWND_TOP, ix, iy, 0, 0,
                          SWP_MOVE);
        }
      WinSetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0,
                      SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);

      // Process the dialog!
      rc = WinProcessDlg(hwndDlg);

      // Destroy window
      WinDestroyWindow(hwndDlg);

      // Hide mouse pointer again, if we're screensaving.
      if (!bOnlyPreviewMode)
        WinShowPointer(HWND_DESKTOP, FALSE);

      return (MRESULT) SSMODULE_NOERROR;

    case WM_SUBCLASS_UNINIT:
    case WM_DESTROY:
      // All kinds of cleanup (the opposite of everything done in WM_CREATE)
      // should come here.

      // Restore mouse pointer, if we're in real screen-saving mode!
      if (!bOnlyPreviewMode)
        WinShowPointer(HWND_DESKTOP, TRUE);
      break;

    case WM_ADJUSTWINDOWPOS:
      if (!bOnlyPreviewMode)
      {
	SWP *pSWP;

	// The following is required so that this window will be on
        // top of the xCenter window, evenif that is set to be always on top!

	// Real screensaving, here we should stay on top!
        // Set WS_TOPMOST flag again!
	WinSetWindowBits(hwnd, QWL_STYLE, WS_TOPMOST, WS_TOPMOST);

	pSWP = (SWP *) mp1;
	pSWP->hwndInsertBehind = HWND_TOP;
        pSWP->fl |= SWP_ZORDER;
      }
      break;
    case WM_PAINT:
      {
        HPS hpsBeginPaint;
        RECTL rclRect;

#ifdef DEBUG_LOGGING
        AddLog("WM_PAINT\n");
#endif

        hpsBeginPaint = WinBeginPaint(hwnd, NULL, &rclRect);

        WinQueryWindowRect(hwnd, &rclRect);

        // Fill with black
        WinFillRect(hpsBeginPaint, &rclRect, CLR_BLACK);

	WinEndPaint(hpsBeginPaint);
	return (MRESULT) FALSE;
      }
    default:
      break;
  }

  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}
コード例 #9
0
MRESULT EXPENTRY EDBarWinProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   switch (msg) {
      // creazione: memorizza testo controllo
      case WM_CREATE: {
         PBARDATA pbd;
         // allocate structure for caching some control data
         if (!(pbd = (PBARDATA)malloc(sizeof(BARDATA)))) return NULL;
         // se presente testo lo azzera
         if (strlen(((PCREATESTRUCT)mp2)->pszText))
            *((PCREATESTRUCT)mp2)->pszText = 0;
         // copy some data
         pbd->fl = ((PCREATESTRUCT)mp2)->flStyle;
         // se bordo non specificato usa il valore 1
         if (!(pbd->fl & CCTL_BORDER7)) pbd->fl |= CCTL_BORDER1;
         if (pbd->fl & BARS_VERTICAL) {          // verticale
            pbd->szl.cx = 2 * (pbd->fl & 0x7);
            pbd->szl.cy = ((PCREATESTRUCT)mp2)->cy;
         } else {                               // orizzontale
            pbd->szl.cx = ((PCREATESTRUCT)mp2)->cx;
            pbd->szl.cy = 2 * (pbd->fl & 0x7);
         } /* endif */
         WinSetWindowBits(hwnd, QWL_STYLE, SS_GROUPBOX, 0xffff);
         WinSetWindowPos(hwnd, 0, 0, 0, pbd->szl.cx, pbd->szl.cy,
                         SWP_SIZE | SWP_NOADJUST);
         WinSetWindowPtr(hwnd, cbWCstc, (PVOID)pbd);
         break;
      }
      // se il controllo Š ridimensionato memorizza nuove dimensioni
      case WM_ADJUSTWINDOWPOS:
         if (((PSWP)mp1)->fl & SWP_SIZE) {
            PBARDATA pbd = (PBARDATA)stGetData(hwnd);
            if (pbd) {
               if (pbd->fl & BARS_VERTICAL) {         // verticale
                  ((PSWP)mp1)->cx = pbd->szl.cx;
                  pbd->szl.cy = ((PSWP)mp1)->cy;
               } else {                               // orizzontale
                  pbd->szl.cx = ((PSWP)mp1)->cx;
                  ((PSWP)mp1)->cy = pbd->szl.cy;
               } /* endif */
            } /* endif */
         } // end if
         return WinDefWindowProc(hwnd, msg, mp1, mp2);
      // sostituisce totalmente procedura controllo statico
      case WM_PAINT: {
         PBARDATA pbd = (PBARDATA)stGetData(hwnd);
         HPS hps;
         RECTL rcl = {0, 0, pbd->szl.cx, pbd->szl.cy};;
         if (pbd &&
             NULLHANDLE != (hps = WinBeginPaint(hwnd, NULLHANDLE, NULL))) {
            WinDrawBorder(hps, &rcl, pbd->fl & 0x7, pbd->fl & 0x7, 0, 0,
                          (pbd->fl & CCTL_RAISED? 0x400: 0x800));
            WinEndPaint(hps);
         } // end if
         return (MRESULT)FALSE;
      } // end case WM_PAINT
      case WM_DESTROY: {
         PBARDATA pbd = (PBARDATA)stGetData(hwnd);
         if (pbd) free(pbd);
      }  break;
   } /* endswitch */
   return pfnwpWCstc(hwnd, msg, mp1, mp2); // default static controls proc
}