コード例 #1
0
void InitDlgItemSpin(
	HWND 	hWindow,
	int  	idControl,
	int		iValue,
	BOOL 	bSigned,
	int  	iMin,
	int		iMax)
{
	HWND hEditControl;
	HWND hSpinControl;

	/* Get the handle to the control */
	if ( !(hEditControl = GetDlgItem( hWindow, idControl ) ) )
		goto Exit;

	if ( !(hSpinControl = GetWindow(hEditControl, GW_HWNDNEXT) ) )
		goto Exit;

	if ( GetDlgCtrlID(hSpinControl) != idControl )
		goto Exit;

	SetWindowWord( hSpinControl, GWW_SPINTYPE, 0 );
	SetWindowWord( hSpinControl, GWW_SPINMIN, iMin );
	SetWindowWord( hSpinControl, GWW_SPINMAX, iMax );
	SetWindowLong( hSpinControl, GWL_SPINSTEP, 0 );
Exit:
	SetDlgItemSpin( hWindow, idControl, iValue, bSigned );
}
コード例 #2
0
ファイル: MSWDISP.C プロジェクト: teriiehina/PitaEmacs
BOOL FAR PASCAL ScrReSize (HWND hWnd, UINT wParam, WORD cx, WORD cy)

/* returns TRUE only if real resizing performed */
{
    BOOL    ChgWidth, ChgHeight;

    if ((wParam != SIZENORMAL) && (wParam != SIZEFULLSCREEN)) {
        return FALSE;
    }
    ChgWidth = (cx != GetWindowWord (hWnd, GWW_SCRCX));
    ChgHeight = (cy != GetWindowWord (hWnd, GWW_SCRCY));
    if (!ChgWidth && !ChgHeight) return FALSE;

    SetWindowWord (hWnd, GWW_SCRCX, cx);
    SetWindowWord (hWnd, GWW_SCRCY, cy);
    if (!InternalRequest) {
        SCREEN  *TopScreen;

        InternalRequest = TRUE;
        TopScreen = first_screen;
	select_screen ((SCREEN *)GetWindowLong (hWnd, GWL_SCRPTR), FALSE);
	if (ChgWidth) {
            newwidth (TRUE, DisplayableColumns (hWnd, cx, &EmacsCM));
        }
	if (ChgHeight) {
	    newsize (TRUE, DisplayableRows (hWnd, cy, &EmacsCM));
	}
	select_screen (TopScreen, FALSE);
	update (FALSE);
	InternalRequest = FALSE;
    }
    return TRUE;
} /* ScrReSize */
コード例 #3
0
ファイル: miopanel.c プロジェクト: mingpen/OpenNT
static BOOL Cls_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
	HWND 			hwndChild;
	TCHAR			szFormat[64],
					szBuffer[64];


#ifndef WIN32
	hwndChild = GetFirstChild(hwnd);
	while (hwndChild)
	{
		SetWindowFont(hwndChild, hFontDialog, FALSE);
		hwndChild = GetNextSibling(hwndChild);
	}
#endif
  	
	LoadString(hInstance, IDS_MIO_TITLE, szFormat, SIZEOF_IN_CHAR(szFormat));
	wsprintf(szBuffer, szFormat, wMIOSlotNumber);
	SetWindowText(hwnd, szBuffer);

	if (hwndChild = GetDlgItem(hwnd, IDC_MIO_TYPE))
	{
		SetWindowWord(hwndChild, GWW_TRAYLEVEL, 1000);
		SetWindowText(hwndChild, mio_card[wMIOSlotNumber - 1].mioType);
	}

	if (hwndChild = GetDlgItem(hwnd, IDC_MIO_DESCRIPTION))
	{
		SetWindowWord(hwndChild, GWW_TRAYLEVEL, 1000);
		SetWindowText(hwndChild, mio_card[wMIOSlotNumber - 1].mioInfo);
	}

	return TRUE;
}
コード例 #4
0
ファイル: CHECKER3.CPP プロジェクト: amitahire/development
long FAR PASCAL _export ChildWndProc(HWND hwnd, 
                                     UINT message, 
                                     UINT wParam,
                                     LONG lParam)
   {
   HDC         hdc;
   PAINTSTRUCT ps;                                     
   RECT        rect;

   switch (message)
      {
      case WM_CREATE :
         {
         SetWindowWord(hwnd, 0,0);
         return 0;
         }
      case WM_LBUTTONDOWN :
         {
         SetWindowWord(hwnd, 0, 1 ^ GetWindowWord(hwnd,0));
         InvalidateRect(hwnd,NULL,FALSE);
         return 0;
         }  
   
      case WM_PAINT :
         {
         TRACE_STR("WM_PAINT..");
         //get the device context handle for use in painting the sucker...
         hdc = BeginPaint(hwnd, &ps);

         GetClientRect(hwnd, &rect);
         Rectangle(hdc,
                   0,
                   0,
                   rect.right,
                   rect.bottom);
         // draw an X if true!          
         if (GetWindowWord(hwnd,0))
            {
            MoveTo(hdc,0         ,0          );
            LineTo(hdc,rect.right,rect.bottom);
            MoveTo(hdc,0         ,rect.bottom);
            LineTo(hdc,rect.right,0          );
            }
         
         EndPaint (hwnd, &ps);
         TRACE_STR("EXIT WM_PAINT...");
         TRACE_STR("EXIT WndProc");
         return 0;      
         }
      }   // switch
   // *********************extremely important!!! ******************      
   // **                   extremely important!!!                 **
   // **                   extremely important!!!                 **
   return DefWindowProc(hwnd,message,wParam,lParam);                
   // **                   extremely important!!!                 **
   // **                   extremely important!!!                 **
   // *********************extremely important!!! ******************      
   }                                                                
コード例 #5
0
ファイル: Dialog.c プロジェクト: ErisBlastar/osfree
BOOL WINAPI
#else
void WINAPI
#endif
EndDialog(HWND hDlg,int Result)
{
    ShowWindow(hDlg,SW_HIDE);
    SetWindowWord(hDlg,DWW_STATUS,1);
    SetWindowWord(hDlg,DWW_RESULT,Result);
#ifdef TWIN32
    return TRUE;
#endif
}
コード例 #6
0
static void DrawBox( HWND hWnd, HDC hDC )  // Assumes zoom box is current view!
/************************************************************************/
{
RECT rFile, rDraw;
HWND hOwner;
LPDISPLAY lpOwnerDisp, lpMyDisp;

hOwner = GetZoomOwner(hWnd);
if (!hOwner)
	return;
lpOwnerDisp = (LPDISPLAY)GetDisplayPtr(hOwner);
lpMyDisp = (LPDISPLAY)GetDisplayPtr(hWnd);
if (!lpOwnerDisp || !lpMyDisp)
	return;

//rDisp = lpMyDisp->DispRect;
rFile = lpMyDisp->FileRect;

// get owners file rect and convert to our file rect

rDraw.left = lpOwnerDisp->FileRect.left-rFile.left;
rDraw.top= lpOwnerDisp->FileRect.top-rFile.top;
rDraw.right= lpOwnerDisp->FileRect.right-rFile.left;
rDraw.bottom= lpOwnerDisp->FileRect.bottom-rFile.top;


// convert into our display rect
File2DispRect(hWnd, &rDraw, &rDraw);

// limit to display rect
IntersectRect(&rDraw, &rDraw, &(lpMyDisp->DispRect));

//rDraw.left++;
//rDraw.top++;

//old way:fRate = FGET(rDisp.right-rDisp.left, rFile.right-rFile.left);
//rDraw.left = FMUL(rDraw.left,fRate);
//rDraw.right = FMUL(rDraw.right,fRate);
//fRate = FGET(rDisp.bottom-rDisp.top, rFile.bottom-rFile.top);
//rDraw.top = FMUL(rDraw.top,fRate);
//rDraw.bottom = FMUL(rDraw.bottom,fRate);

// Invert the box
InvertBox(hDC, &rDraw);

// remeber box
SetWindowWord( hWnd, GWW_ZOOMBOXLEFT, (WORD)rDraw.left);
SetWindowWord( hWnd, GWW_ZOOMBOXTOP, (WORD)rDraw.top);
SetWindowWord( hWnd, GWW_ZOOMBOXRIGHT, (WORD)rDraw.right);
SetWindowWord( hWnd, GWW_ZOOMBOXBOTTOM, (WORD)rDraw.bottom);
}
コード例 #7
0
ファイル: waitdlgx.c プロジェクト: mingpen/OpenNT
//--------------------------------------------------------------------
// Function:    Cls_OnTimer
// 
// Description: 
//
// Input:       hwnd  - 
//              id    - 
//              
// Modifies:    
//
// Returns:     
//
//--------------------------------------------------------------------
static void Cls_OnTimer(HWND hwnd, UINT id)
{
    HWND                    hwndChild;
    WORD                    percent;

    if (timerCount < NUM_TICKS) 
    {
      
        if (hwndChild = GetDlgItem(hwnd, IDC_CLOCK_ICON))
        {
            Static_SetIcon(hwndChild, hTimers[timerCount % 8]); 
        }

        if (hwndChild = GetDlgItem(hwnd, IDC_PROGRESS_BAR))
        {
            percent = (WORD)((timerCount * 3) + 7);
            SetWindowWord(hwndChild, GWW_TRAYLEVEL, percent);
            InvalidateRect(hwndChild, NULL, FALSE);
        }

        timerCount++;
    }
    else 
    {
        EndDialog(hwnd, id);
    }

}
コード例 #8
0
void InitDlgItemSpinFixed(
	HWND   hWindow,
	int    idControl,
	LFIXED fValue,
	BOOL   bConvert,
	LFIXED fMin,
	LFIXED fMax)
{
	HWND hEditControl;
	HWND hSpinControl;

	/* Get the handle to the control */
	if ( !(hEditControl = GetDlgItem( hWindow, idControl ) ) )
		goto Exit;

	if ( !(hSpinControl = GetWindow(hEditControl, GW_HWNDNEXT) ) )
		goto Exit;

	if ( GetDlgCtrlID(hSpinControl) != idControl )
		goto Exit;

	SetWindowWord( hSpinControl, GWW_SPINTYPE, 1 );
	SetWindowLong( hSpinControl, GWL_FSPINMIN, fMin );
	SetWindowLong( hSpinControl, GWL_FSPINMAX, fMax );
	SetWindowLong( hSpinControl, GWL_SPINSTEP, 0 );

Exit:
	SetDlgItemSpinFixed( hWindow, idControl, fValue, bConvert );
}
コード例 #9
0
static void EraseBox( HWND hWnd, HDC hDC )
/************************************************************************/
{
RECT rInvert;

rInvert.left   = GetWindowWord(hWnd, GWW_ZOOMBOXLEFT);
rInvert.top    = GetWindowWord(hWnd, GWW_ZOOMBOXTOP);
rInvert.right  = GetWindowWord(hWnd, GWW_ZOOMBOXRIGHT);
rInvert.bottom = GetWindowWord(hWnd, GWW_ZOOMBOXBOTTOM);

// invert the box
InvertBox(hDC, &rInvert);

SetWindowWord( hWnd, GWW_ZOOMBOXLEFT, 0);
SetWindowWord( hWnd, GWW_ZOOMBOXTOP, 0);
SetWindowWord( hWnd, GWW_ZOOMBOXRIGHT, 0);
SetWindowWord( hWnd, GWW_ZOOMBOXBOTTOM, 0);
}
コード例 #10
0
LOCAL BOOL ZoomBox_OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct)
/***********************************************************************/
{
LPDISPLAY lpMyDisplay;

hZoomWindow = hWnd;
if ( !(lpMyDisplay = (LPDISPLAY)Alloc((long)sizeof(DISPLAY))) )
	return( (BOOL)-1 );
StuffZoomDisplay(hWnd, lpMyDisplay);
SetImagePtr (hWnd, NULL);
SetDisplayPtr (hWnd, lpMyDisplay);
SetWindowWord( hWnd, GWW_ZOOMBOXLEFT, 0);	// postion in pixels
SetWindowWord( hWnd, GWW_ZOOMBOXTOP, 0);	// ''
SetWindowWord( hWnd, GWW_ZOOMBOXRIGHT, 0);	// ''
SetWindowWord( hWnd, GWW_ZOOMBOXBOTTOM, 0);	// ''
SetDisplayHook(hWnd, &UpdateBoxHook);
return(TRUE);
}
コード例 #11
0
LOCAL  void PalPicker_NewSelect( HWND hWindow, int iOldSelect, int iNewSelect )
/***********************************************************************/
{
HDC hDC;

hDC = GetDC(hWindow);
PalPicker_Select(hWindow, hDC, iOldSelect, OFF);
PalPicker_Select(hWindow, hDC, iNewSelect, ON);
ReleaseDC(hWindow, hDC);
SetWindowWord(hWindow, GWW_PALINDEX, iNewSelect);
}
コード例 #12
0
ファイル: wnddata.c プロジェクト: ErisBlastar/osfree
/* 
** Allocate memory space for the child window's data. 
*/
BOOL __far __pascal AllocChildWndData( HWND hWnd )
{
  HWNDDATA hWndData;
  
  /* Allocate memory. */
  if( ! GlobalAllocMem( hWnd, &hWndData, sizeof( WNDDATA ) ) ) return FALSE;
  
  /* Save handle in the window's extrabyte. */
  SetWindowWord( hWnd, 0, (WORD) hWndData );

  /* Success. */
  return( TRUE );
}
コード例 #13
0
void SetDlgItemSpinLimits(
	HWND hWindow,
	int  idControl,
	int  iMin,
	int  iMax)
{
	HWND hEditControl;
	HWND hSpinControl;

	/* Get the handle to the control */
	if ( !(hEditControl = GetDlgItem( hWindow, idControl ) ) )
		return;

	if ( !(hSpinControl = GetWindow(hEditControl, GW_HWNDNEXT) ) )
		return;

	if ( GetDlgCtrlID(hSpinControl) != idControl )
		return;

	SetWindowWord( hSpinControl, GWW_SPINMIN, iMin );
	SetWindowWord( hSpinControl, GWW_SPINMAX, iMax );
}
コード例 #14
0
ファイル: wnddata.c プロジェクト: ErisBlastar/osfree
/* 
** Free memory space for the child window's data. 
*/
void __far __pascal FreeChildWndData( HWND hWnd )
{
  HWNDDATA hWndData;

  
  /* get window data handle. */
  hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 );
  
  /* Free memory. */
  GlobalFree( hWndData );
  
  /* Save handle in the window's extrabyte. */
  SetWindowWord( hWnd, 0, 0 );
}
コード例 #15
0
void PalPicker_Init(HWND hWindow, LPCOLORMAP lpColorMap, int iSelect)
/***********************************************************************/
{
int r, c;
RECT SelectRect;

SetWindowLong(hWindow, GWL_COLORMAP, (long)lpColorMap);
SetWindowWord(hWindow, GWW_PALINDEX, iSelect);
if (lpColorMap)
	{
	InvalidateRect(hWindow, NULL, TRUE);
	}
else
	{
	r = iSelect / 16;
	c = iSelect % 16;
	PalPicker_GetRect(hWindow, r, c, &SelectRect);
	InvalidateRect(hWindow, &SelectRect, TRUE);
	}
}
コード例 #16
0
//***********************************************************************
void CJungleScene::ShowPuzzle1Buttons( HWND hWnd, BOOL bShow )
//***********************************************************************
{
	static int iPosX[12] =
	{ 211, 264, 317, 370, 423, 476, 211, 264, 317, 370, 423, 476 };
	static int iPosY[12] =
	{ 364, 364, 364, 364, 364, 364, 408, 408, 408, 408, 408, 408 };

	for (int idx = 0 ; idx < NUM_PUZZLE_BUTTONS ; idx++)
	{
		HWND hControl = GetDlgItem(hWnd, IDC_PUZ_BTN1 + 2*idx);
		SetWindowWord( hControl, GWW_STATE, 0 );
		if ( bShow )
		{
			SetWindowPos( hControl, NULL, iPosX[idx], iPosY[idx], 0, 0,
				SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE );
			ShowWindow( hControl, SW_SHOW );
		}
		else
			ShowWindow( hControl, SW_HIDE );
	}

	nMatches = 0;
}
コード例 #17
0
ファイル: Dialog.c プロジェクト: ErisBlastar/osfree
LRESULT WINAPI
DefDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
    DLGPROC	f;
    LRESULT	rc;
    HBRUSH	hBrush;
    HFONT   hFont;
    RECT rcClient;
    HWND hWndChild, hWndFocus;
    DWORD dwStyle;
    WORD wTmp;
    HCLASS32 hDialog32;

    APISTR((LF_APICALL,"DefDlgProc(HWND=%x,UINT=%x,WPARAM=%x,LPARAM=%lx)\n",
            hDlg,iMessage,wParam,lParam));

    if (!IsWindow(hDlg)) {
        APISTR((LF_APIFAIL,"DefDlgProc: returns LRESULT 0\n"));
        return 0L;
    }

    if (iMessage == WM_CONVERT) {
        if (!lpDialogBinToNat) {
            hDialog32 = FindClass(TWIN_DIALOGCLASS,(HINSTANCE)0);
            lpDialogBinToNat = (WNDPROC)GetClassHandleLong(
                                   hDialog32,GCL_BINTONAT);
        }
        if (lpDialogBinToNat) {
            rc = lpDialogBinToNat(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;
        } else {
            APISTR((LF_APIFAIL,"DefDlgProc: returns LRESULT 0\n"));
            return (LRESULT)0;
        }
    }

    if ( (f = (DLGPROC) GetWindowLong(hDlg,DWL_DLGPROC)) ) {
        rc = CallWindowProc(
#ifdef	STRICT
                 (WNDPROC)f,
#else
                 (FARPROC)f,
#endif
                 hDlg,iMessage,wParam,lParam);
    }
    else  rc = 0L;

    if (!IsWindow(hDlg)) {	/* dialog has been destroyed in the callback */
        APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
        return rc;
    }

    if(LOWORD(rc) == 0) {
        switch(iMessage) {
        case WM_ERASEBKGND:
            GetClientRect(hDlg, &rcClient);
            hBrush = (HBRUSH)SendMessage(hDlg,
                                         GET_WM_CTLCOLOR_MSG(CTLCOLOR_DLG),
                                         GET_WM_CTLCOLOR_MPS(
                                             (HDC)wParam,hDlg,CTLCOLOR_DLG));
            FillRect((HDC)wParam,&rcClient,hBrush);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n"));
            return (LRESULT)1;

        case WM_SHOWWINDOW:
            /* if we are hiding, save the focus */
            if (!wParam)
                SaveDlgFocus(hDlg);
            rc =  DefWindowProc(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

        case WM_SYSCOMMAND:
            if ((wParam & 0xfff0) == SC_MINIMIZE)
                SaveDlgFocus(hDlg);

            rc = DefWindowProc(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

        case WM_ACTIVATE:
            if GET_WM_ACTIVATE_STATE(wParam,lParam)
                RestoreDlgFocus(hDlg);
            else
                SaveDlgFocus(hDlg);
            break;

        case WM_SETFOCUS:
            if (!RestoreDlgFocus(hDlg))
                DlgSetFocus(GetFirstDlgTabItem(hDlg));
            break;

        case WM_CLOSE:
            hWndChild = GetDlgItem(hDlg, IDCANCEL);
            if (hWndChild) {
                dwStyle = GetWindowLong(hDlg,GWL_STYLE);
                if (dwStyle & WS_DISABLED) {
                    MessageBeep(0);
                } else
                    PostMessage(hDlg,WM_COMMAND,
                                GET_WM_COMMAND_MPS(IDCANCEL,
                                                   hWndChild,BN_CLICKED));
            }
            break;

        case WM_NCDESTROY:
            SetWindowWord(hDlg,DWW_STATUS,1);
            if ((hFont = (HFONT)GetWindowWord(hDlg, DWW_HFONT))) {
                DeleteObject(hFont);
                SetWindowWord(hDlg,DWW_HFONT,0);
            }
            DefWindowProc(hDlg,iMessage,wParam,lParam);
            break;

        case DM_SETDEFID:
            SetWindowWord(hDlg,DWW_DEFID,wParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n"));
            return (LRESULT)1;

        case DM_GETDEFID:
            wTmp = GetWindowWord(hDlg,DWW_DEFID);
            if (wTmp) {
                rc = MAKELRESULT(wTmp, DC_HASDEFID);
                APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
                return rc;
            } else {
                APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 0\n"));
                return (LRESULT)0;
            }

        case WM_NEXTDLGCTL:
            hWndFocus = GetFocus();
            if (LOWORD(lParam)) {
                if (!hWndFocus)
                    hWndFocus = hDlg;
                hWndChild = (HWND)wParam;
            }
            else {
                if (!hWndFocus) {
                    /* set to the first tab item */
                    hWndChild = GetFirstDlgTabItem(hDlg);
                    hWndFocus = hDlg;
                }
                else {
                    if (!IsChild(hDlg,hWndFocus))
                        return (LRESULT)1;
                    hWndChild = GetNextDlgTabItem(hDlg,
                                                  hWndFocus,(BOOL)wParam);
                }
            }

            DlgSetFocus(hWndChild);
            CheckDefPushButton(hDlg,hWndFocus,hWndChild);

            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n"));
            return (LRESULT)1;

        case WM_GETFONT:
            rc = (LRESULT)GetWindowWord(hDlg,DWW_HFONT);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

        case WM_SETFONT:
            SetWindowWord(hDlg,DWW_HFONT,(HFONT)wParam);
            if (LOWORD(lParam))
                InvalidateRect(hDlg,NULL,TRUE);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",0));
            return 0L;

        case WM_VKEYTOITEM:
        case WM_COMPAREITEM:
        case WM_CHARTOITEM:
        case WM_INITDIALOG:
            break;

        case WM_MOUSEACTIVATE:

            rc = (LRESULT)MA_ACTIVATE;
            if ((int)(short)LOWORD(lParam) == HTCAPTION)
                rc = (LRESULT)MA_NOACTIVATE;
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

#ifdef	TWIN32
        case WM_CTLCOLORMSGBOX:
        case WM_CTLCOLORBTN:
        case WM_CTLCOLORDLG:
        case WM_CTLCOLORSTATIC:
            rc =  GetStockObject(LTGRAY_BRUSH);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;
#endif
        default:
            rc = DefWindowProc(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;
        }
    }
コード例 #18
0
ファイル: libmain.c プロジェクト: ErisBlastar/osfree
long __far __pascal __export SDKWndProc( HWND hWnd, WORD Msg, WORD wParam, LONG lParam )
{
  CREATESTRUCT __far * lpCreateStruct;   /* Data passed in LPARAM. */
  HWND __far * hTwinViewWnd;             /* Handle to the TWINVIEW.EXE main window. */

  HWNDDATA        hWndData ;             /* Handle to window extrabyte data. */
  FPWNDDATA       fpWndData ;            /* Pointer to window extrabyte data. */
  
  char lpszClassName[ MAX_CLASS_NAME ];  /* Name of a window's class. */
  
  HWND hHelpWnd;                         /* Handle to a help window. */

  
  /* 
  ** Handle WinHelp special messages - WM_WINDOC & WM_WINHELP. 
  */

  if( Msg == GetWINHELPMsg() || Msg == GetWINDOCMsg() )
  {
    /* Get window list. */
    hWndData = (HWNDDATA) GetWindowWord (hWnd, TVL_WNDEXTRABYTES ) ;
    fpWndData = (FPWNDDATA) GlobalLock( hWndData );

    /* Get/create the application's help window. */
    hHelpWnd = GetHelpWindow( hWnd, (HWND) wParam, &(fpWndData)->hWndInfoList );
          
    /* Send message to correct help window. */  
    if( hHelpWnd != 0 )
    {
      /* Route the message to the correct help window. */
      SendMessage( hHelpWnd, Msg, wParam, lParam );
    }

    return 0 ;
  }


  /* 
  ** Other Windows messages. 
  */
  switch (Msg)
  {
    case WM_CREATE:
    {
      /* Allocate memory for window private data. */
      hWndData = GlobalAlloc ( LMEM_MOVEABLE | LMEM_ZEROINIT, sizeof (WNDDATA) ) ;
                              
      /* Error retrieving memory. */
      if ( hWndData == NULL ) 
      {
        /* Allocation error. */ 
        MsgBox( GetLibInst(), hWnd, IDS_ERRORTITLE, IDS_MEMORYALLOC, MB_ICONHAND | MB_OK );
        return -1;
      }

      /* Initialize the window data. */
      fpWndData = (FPWNDDATA) GlobalLock( hWndData );
      fpWndData->hTwinViewWnd = 0;
      fpWndData->hWndInfoList = 0;
      GlobalUnlock( hWndData );

      /* Save handle to allocated window data. */
      SetWindowWord ( hWnd, TVL_WNDEXTRABYTES, (WORD) hWndData ) ;
        
      /*
      ** If we are running under TWINVIEW.EXE when the last help 
      ** window is tell TWINVIEW.EXE to close also.  To do this we
      ** will need to save the window handle for TWINVIEW.EXE's 
      ** main window.
      */

      /* Get class of window. */
      GetClassName( hWnd, (LPSTR) lpszClassName, MAX_CLASS_NAME );

      /* 
      ** If we were launched by TWINVIEW.EXE, via a MS-Windows
      ** WinHelp() call, save TWINVIEW's window handle? 
      */
      if( _fstricmp( lpszClassName, MS_WINHELP_CLASS ) == 0 )
      {
        /* Get TWINVIEW's window handle.*/
        lpCreateStruct = ( CREATESTRUCT __far * ) lParam;
        hTwinViewWnd = ( HWND __far * ) lpCreateStruct->lpCreateParams;
      
        /* Save TWINVIEW's window handle.*/
        fpWndData = (FPWNDDATA) GlobalLock( hWndData );
        fpWndData->hTwinViewWnd = *hTwinViewWnd;
        GlobalUnlock( hWndData );
      }
            
      /* Success. */
      return 0;
    }
    
    
    /* 
    ** A help window closed - see if we should close this main redirector 
    ** window. 
    */
    case HELPWM_CLOSE:
    {
      /* Get window list. */
      hWndData = (HWNDDATA) GetWindowWord (hWnd, TVL_WNDEXTRABYTES ) ;
      fpWndData = (FPWNDDATA) GlobalLock( hWndData );
      
      /* Remove the window from the list. */
      RemoveHelpWndInfo( &(fpWndData)->hWndInfoList, (HWND) wParam );
          
      /* Still have help windows under this window. */
      if( GetHelpWndCount( fpWndData->hWndInfoList ) != 0 ) 
      {
        GlobalUnlock( hWndData );
        return 0;
      }
      
      /* 
      ** Last help window - close this parent window. 
      */
      
      /* 
      ** If we were launched by TWINVIEW.EXE, via a MS-Windows
      ** WinHelp() call, close down TWINVIEW.EXE.
      */
      GetClassName( hWnd, (LPSTR) lpszClassName, MAX_CLASS_NAME );
          
      if( _fstricmp( lpszClassName, MS_WINHELP_CLASS ) == 0 )
      {
        /* Tell twinview to close down. */
        PostMessage( fpWndData->hTwinViewWnd, WM_SYSCOMMAND, SC_CLOSE, 0L );
      }
                
      GlobalUnlock( hWndData );
              
      /* Destroy the window. */
      DestroyWindow( hWnd ) ;
              
      return 0;
    }

    
    case WM_DESTROY:
    {
      hWndData = (HWNDDATA) GetWindowWord (hWnd, TVL_WNDEXTRABYTES ) ;
      GlobalFree ( hWndData ) ;
      return 0 ; 
    }
  }

  // Pass unprocessed message to DefWindowProc
  return DefWindowProc (hWnd, Msg, wParam, lParam) ;
}
コード例 #19
0
ファイル: trays.c プロジェクト: mingpen/OpenNT
//--------------------------------------------------------------------
// Function:    OnActivateDialog
// 
// Description: 
//
// Input:       hwnd  - 
//              
// Modifies:    
//
// Returns:     
//
//--------------------------------------------------------------------
static void OnActivateDialog(HWND hwnd)
{
    int     i;
    TCHAR   szBuffer[64],
            szFormat[32];
    WORD    wLevel;
    HWND    hwndChild;

    for (i = 0; i < MEDIA_TRAY_MAX_NUMBER; i++)
    {
        if (media_tray[i].bInstalled IS TRUE) 
        {
            loadMediaType(hwnd, IDC_MEDIA_TYPE1 + i, media_tray[i].uMediaTypeID);
        }
        else 
        {
            if (hwndChild = GetDlgItem(hwnd, IDC_MEDIA_TYPE1 + i))
                ShowWindow(hwndChild, SW_HIDE);
            if (hwndChild = GetDlgItem(hwnd, IDC_TRAY1_NAME + i))
                ShowWindow(hwndChild, SW_HIDE);
        }
    }

    LoadString(hInstance, IDS_PERCENT, szFormat, SIZEOF_IN_CHAR(szFormat));

    if (hwndChild = GetDlgItem(hwnd, IDC_MEDIA_STATUS1))
    {
        SetBuf(    szBuffer, sizeof(szBuffer), szFormat, (signed short) media_tray[0].uLevel, &wLevel);
        SetWindowWord(hwndChild, GWW_TRAYLEVEL, wLevel);
        SetWindowText(hwndChild, szBuffer);
    }    

    if (hwndChild = GetDlgItem(hwnd, IDC_MEDIA_STATUS2))
    {
        SetBuf(    szBuffer, sizeof(szBuffer), szFormat, (signed short) media_tray[1].uLevel, &wLevel);
        SetWindowWord(hwndChild, GWW_TRAYLEVEL, wLevel);
        SetWindowText(hwndChild, szBuffer);
    }    

    if (hwndChild = GetDlgItem(hwnd, IDC_MEDIA_STATUS3))
    {
        SetBuf(    szBuffer, sizeof(szBuffer), szFormat, (signed short) media_tray[2].uLevel, &wLevel);
        SetWindowWord(hwndChild, GWW_TRAYLEVEL, wLevel);
        SetWindowText(hwndChild, szBuffer);
    }    

    if (hwndChild = GetDlgItem(hwnd, IDC_MEDIA_STATUS4)) 
    {
        if (media_tray[3].bInstalled IS TRUE) 
        {
            SetBuf(    szBuffer, sizeof(szBuffer), szFormat, (signed short) media_tray[3].uLevel, &wLevel);
            SetWindowWord(hwndChild, GWW_TRAYLEVEL, wLevel);
            SetWindowText(hwndChild, szBuffer);
        }    
        else ShowWindow(hwndChild, SW_HIDE);
    }

    if (hwndChild = GetDlgItem(hwnd, IDC_MEDIA_STATUS5)) 
    {
        if (media_tray[4].bInstalled IS TRUE) 
        {
            SetBuf(    szBuffer, sizeof(szBuffer), szFormat, (signed short) media_tray[4].uLevel, &wLevel);
            SetWindowWord(hwndChild, GWW_TRAYLEVEL, wLevel);
            SetWindowText(hwndChild, szBuffer);
        }
        else ShowWindow (hwndChild, SW_HIDE);
    }
}
コード例 #20
0
static void Video_OnSetState(HWND hWindow, BOOL fState)
/***********************************************************************/
{
	SetWindowWord( hWindow, GWW_STATE, fState );
}
コード例 #21
0
ファイル: POWDDE.C プロジェクト: Madzi/POW
HDDEDATA FAR PASCAL _export PowDdeServerProc (UINT type,UINT fmt,HCONV hconv,HSZ hsz1,HSZ hsz2,HDDEDATA hdata,DWORD dwData1,DWORD dwData2)
{                          
    LPSTR exec;
    HWND hWnd;                 
    DWORD size;
    HDDEDATA hDat;
    
    switch (type) {                  
    
        case XTYP_CONNECT:
            return (HDDEDATA)IsTopic(hsz1);
        
        case XTYP_EXECUTE:
        { 
            char buf[1000];
            
            if (IsTopic(hsz1)) {
                DdeGetData(hdata,buf,sizeof(buf),0);
                exec=GetExecData(buf);
                
                if (IsCommand(buf,"openfile")) {        
                    if (*exec && (hWnd=AlreadyOpen(exec)))
                        BringWindowToTop(hWnd);
                    else {
                        #ifndef _WIN32
                           DownStr(exec);
                        #endif
                        AddFile(exec);
                    }
                    return (HDDEDATA)DDE_FACK;    
                }

                else if (IsCommand(buf,"newfile")) {
                    hWnd=AddFile(0);
                    if (hWnd && *exec) {
                        HWND old;
                        if (old=AlreadyOpen(exec))
                            SendMessage (hwndMDIClient,WM_MDIDESTROY,(WPARAM)old,0L);
                        #ifndef _WIN32
                           DownStr(exec);
                        #endif
                        SetWindowText(hWnd,exec);
                        SetWindowWord(hWnd,GWW_UNTITLED,0);
                    }
                    return (HDDEDATA)DDE_FACK;    
                }

                else if (IsCommand(buf,"savefile")) {
                    if (GetActiveEditWindow(hwndMDIClient)) {
                        if (*exec) {
                            #ifndef _WIN32
                              AnsiLower(exec);
                            #endif
                            SetWindowText(GetActiveEditWindow(hwndMDIClient),exec);
                            SetWindowWord(GetActiveEditWindow(hwndMDIClient),GWW_UNTITLED,0);
                        }             
                        SendMessage(hwndFrame,WM_COMMAND,IDM_FILESAVE,0);
                    }    
                    return (HDDEDATA)DDE_FACK;    
                }

                else if (IsCommand(buf,"activate")) {
                    if (*exec && (hWnd=AlreadyOpen(exec)))
                        BringWindowToTop(hWnd);         
                    return (HDDEDATA)DDE_FACK;
                }

                else if (IsCommand(buf,"appendtext") || IsCommand(buf,"addtext")) {
                    if (*exec && GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient)))
                        EditAddText(GetActiveEditWindow(hwndMDIClient),exec);
                    return (HDDEDATA)DDE_FACK;
                }

                else if (IsCommand(buf,"inserttext")) {
                    if (*exec && GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient)))
                        EditInsertText(GetActiveEditWindow(hwndMDIClient),exec);
                    return (HDDEDATA)DDE_FACK;
                }

                else if (IsCommand(buf,"appendfile") || IsCommand(buf,"addtext")) {
                    if (*exec && GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient))) {
                        EditGotoPos(GetActiveEditWindow(hwndMDIClient),-1,-1);
                        InsertFile(exec);
                    }
                    return (HDDEDATA)DDE_FACK;
                }

                else if (IsCommand(buf,"insertfile")) {
                    if (*exec && GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient)))
                        InsertFile(exec);
                    return (HDDEDATA)DDE_FACK;
                }

                else if (IsCommand(buf,"showposition")) {
                    /* go to line/col of a given file (open if necessary) */
                    if (*exec) {
                        char *file,*sline,*scol;
                        int line=-1,col=-1;
                            
                        file=strtok(exec," ");
                        if (file) {
                            /* read position */
                            sline=strtok(NULL," ");
                            if (sline) {
                                line=atoi(sline);
                                scol=strtok(NULL," ");
                                if (scol)
                                    col=atoi(scol);
                            }
                                               
                            /* display the file */
                        if (hWnd=AlreadyOpen(file))
                            BringWindowToTop(hWnd);
                        else {
                            #ifndef _WIN32
                               DownStr(file);
                            #endif
                            AddFile(file);
                        }
                                              
                        /* set caret to given position */
                            EditGotoPos(GetActiveEditWindow(hwndMDIClient),line,col);
                        }
                    }
                    return (HDDEDATA)DDE_FACK;
                }

                else if (IsCommand(buf,"addtool")) {
                    /* create a new tool */
                    if (*exec) {
                        LPSTR lp;
                        char *name,*cmd,*dir,*options;
                        BOOL menu,askArg,toTop;
                        int buttonId;

                        name=cmd=dir=options=NULL;
                        menu=askArg=toTop=FALSE;
                        buttonId=0;

                        /* read tool name */
                        name=strtok(exec,",");
                        if (name) {
                            cmd=strtok(NULL,",");
                            if (cmd) {
                                dir=strtok(NULL,",");
                                if (dir) {
                                    options=strtok(NULL,",");
                                    if (options) {
                                       lp=strtok(NULL,",");
                                       if (lp) {
                                           menu=(BOOL)atoi(lp);
                                           lp=strtok(NULL,",");
                                           if (lp) {
                                               buttonId=atoi(lp);
                                               lp=strtok(NULL,",");
                                               if (lp) {
                                                   toTop=(BOOL)atoi(lp);
                                                   lp=strtok(NULL,",");
                                                   if (lp) {
                                                       askArg=(BOOL)atoi(lp);
                                                   }
                                               }
                                           }
                                       }
                                    }
                                }
                            }
                        }
                        if (strcmp(dir," ")==0) dir="";
                        if (strcmp(options," ")==0) options="";
                        if (name && cmd && *name && *cmd && (menu || buttonId))
                            ToolAdd(name,cmd,dir,options,menu,buttonId,toTop,askArg);
                    }
                    return (HDDEDATA)DDE_FACK;
                }

                else if (IsCommand(buf,"deletetool")) {
                    /* remove an external tool */
                    if (*exec)
                        ToolDelete(exec);
                    return (HDDEDATA)DDE_FACK;
                }
            }
            return (HDDEDATA)DDE_FNOTPROCESSED;
        }
    
        case XTYP_POKE:
        {
          if (IsTopic(hsz1)) 
          {
            if (IsEqualString(hsz2,"editbuffer")) 
            {        
              if (GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient)))  
              {
                LPSTR lBuf;                                              
                if (lBuf=DdeAccessData(hdata,(LPDWORD)&size)) 
                {
                  EditResetContent(GetActiveEditWindow(hwndMDIClient));
                  EditAddText(GetActiveEditWindow(hwndMDIClient),lBuf);
                  DdeUnaccessData(hdata);
                }    
              }
              return (HDDEDATA)DDE_FACK;
            }
          }    
          return (HDDEDATA)DDE_FNOTPROCESSED;
        }
     
        case XTYP_REQUEST:     
        {                      
          if (IsTopic(hsz1)) 
          {
            if (IsEqualString(hsz2,"activefile")) 
            {        
              if (GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient)))  
              {
                long len;
                char name[100];
                HSZ hitem;
                        
                hitem=DdeCreateStringHandle(ddeInstId,(LPSTR)"activefile",CP_WINANSI);
                len=GetWindowText(GetActiveEditWindow(hwndMDIClient),(LPSTR)name,sizeof(name));
                return DdeCreateDataHandle(ddeInstId,(LPSTR)name,len+1,0,hitem,CF_TEXT,0);
              }
            }
            else if (IsEqualString(hsz2,"editbuffer")) 
            {        
              if (GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient)))  
              {
                LPSTR lp;
                HGLOBAL h;
                if (h=EditGetText(GetActiveEditWindow(hwndMDIClient))) 
                {
                  HSZ hitem;
                          
                  hitem=DdeCreateStringHandle(ddeInstId,(LPSTR)"editbuffer",CP_WINANSI);
                  lp=GlobalLock(h);
                  hDat=DdeCreateDataHandle(ddeInstId,lp,GlobalSize(h),0,hitem,CF_TEXT,0);
                  GlobalUnlock(h);
                  GlobalFree(h);
                }
                else 
                  hDat=0;
                return hDat;
              }
            }
            else if (IsEqualString(hsz2,"compiler")) 
            {        
              /* return name of active compiler interface dll */
              char name[100];
              HSZ hitem;
                        
              hitem=DdeCreateStringHandle(ddeInstId,(LPSTR)"compiler",CP_WINANSI);
              strcpy(name,actConfig.compiler);
              return DdeCreateDataHandle(ddeInstId,(LPSTR)name,strlen(name)+1,0,hitem,CF_TEXT,0);
            }
            else if (IsEqualString(hsz2,"executable")) 
            {        
              /* return name of target executale */
              BOOL isExecutable;
              //FARPROC lpfn;                  
              char name[500];
              HSZ hitem;
                    
              if (IsCompilerInterfaceLoaded()) 
              {
                if (!*actPrj) 
                {
                  RemoveMessageWindow();
                  if (GetActiveEditWindow(hwndMDIClient) && IsEditWindow(GetActiveEditWindow(hwndMDIClient)) && !GetWindowWord(GetActiveEditWindow(hwndMDIClient),GWW_UNTITLED)) 
                  {
                    SetDefaultProjectName();
                    isExecutable=(*compGetTarget)(hCompData,(LPSTR)name);
                    if (*name && *RunArgs) 
                    { 
                      /* append run arguments (as string included in "") */
                      strcat(name," \"");
                      strcat(name,RunArgs);
                      strcat(name,"\"");
                    }
                  }
                  else *name=0;
                }
                else 
                  isExecutable=(*compGetTarget)(hCompData,(LPSTR)name);
              }
              else *name=0;
                    
              hitem=DdeCreateStringHandle(ddeInstId,(LPSTR)"executable",CP_WINANSI);
              return DdeCreateDataHandle(ddeInstId,(LPSTR)name,strlen(name)+1,0,hitem,CF_TEXT,0);
            }
          }
          return (HDDEDATA) NULL;
        }    
    }                                        
    if (type&XCLASS_FLAGS)
        return (HDDEDATA)DDE_FNOTPROCESSED;
    else
        return (HDDEDATA)NULL;              
}
コード例 #22
0
ファイル: winX.c プロジェクト: calumchisholm/XPilotNG-web
LRESULT CALLBACK WinXwindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
                                LPARAM lParam)
{
    switch (uMsg) {
    case WM_CREATE:
    {
        LPCREATESTRUCT lpcs = (LPCREATESTRUCT) lParam;
        int xidno = (int) lpcs->lpCreateParams;

        Trace("WM_CREATE %d %d/%d %s:%d\n", xidno, lpcs->cx, lpcs->cy,
              xid[xidno].any.file, xid[xidno].any.line);
        WinXCreateBitmapForXid(hwnd, xidno, lpcs->cx, lpcs->cy);
        SetWindowWord(hwnd, 0, (WORD) xidno);
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }

    case WM_DESTROY:
    {
        XID xidno = (int) GetWindowWord(hwnd, 0);

        if (Widget_window(motd_viewer) == xidno)
            Motd_destroy();
        if (Widget_window(keys_viewer) == xidno)
            Keys_destroy();
        WinXDeleteDraw(xidno);
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }

    case WM_SIZE:
    {
        int xidno = (int) GetWindowWord(hwnd, 0);
        if (xidno > 0 && xidno < MAX_XIDS && xid[xidno].hwnd.hBmp) {
            int width = LOWORD(lParam);
            int height = HIWORD(lParam);
            Trace("WM_SIZE   %d %d/%d %s:%d\n", xidno, width, height,
                  xid[xidno].any.file, xid[xidno].any.line);
            WinXCreateBitmapForXid(hwnd, xidno, width, height);
        }
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    case WM_LBUTTONDOWN:
    {
        int xidno = (int) GetWindowWord(hwnd, 0);
        if (xid[xidno].hwnd.event_mask & ButtonPressMask) {
            XEvent event;
            XButtonEvent *button = (XButtonEvent *) & event;
            POINT pt;

            pt.x = LOWORD(lParam);
            pt.y = HIWORD(lParam);
            MapWindowPoints(xid[xidno].hwnd.hWnd, xid[topWindow].hwnd.hWnd,
                            &pt, 1);
            button->type = ButtonPress;
            button->window = xidno;
            button->x = LOWORD(lParam);
            button->y = HIWORD(lParam);
            button->x_root = pt.x;
            button->y_root = pt.y;
            button->button = Button1;
            win_xevent(event);
        }
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    case WM_LBUTTONUP:
    {
        int xidno = (int) GetWindowWord(hwnd, 0);

        if (xid[xidno].hwnd.event_mask & ButtonReleaseMask) {
            XEvent event;
            XButtonEvent *button = (XButtonEvent *) & event;

            Trace("ButtonUp in %d %s:%d\n", xidno, xid[xidno].any.file,
                  xid[xidno].any.line);
            button->type = ButtonRelease;
            button->window = xidno;
            button->x = LOWORD(lParam);
            button->y = HIWORD(lParam);
            button->button = Button1;
            if (win_xevent(event) == -1) {
                WinXExit();
            }
            return (0);
        }
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    case WM_MBUTTONDOWN:
    {
        int xidno = (int) GetWindowWord(hwnd, 0);
        if (xid[xidno].hwnd.event_mask & ButtonPressMask) {
            XEvent event;
            XButtonEvent *button = (XButtonEvent *) & event;
            POINT pt;

            pt.x = LOWORD(lParam);
            pt.y = HIWORD(lParam);
            MapWindowPoints(xid[xidno].hwnd.hWnd, xid[topWindow].hwnd.hWnd,
                            &pt, 1);
            button->type = ButtonPress;
            button->window = xidno;
            button->x = LOWORD(lParam);
            button->y = HIWORD(lParam);
            button->x_root = pt.x;
            button->y_root = pt.y;
            button->button = Button2;
            win_xevent(event);
        }
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    case WM_MBUTTONUP:
    {
        int xidno = (int) GetWindowWord(hwnd, 0);

        if (xid[xidno].hwnd.event_mask & ButtonReleaseMask) {
            XEvent event;
            XButtonEvent *button = (XButtonEvent *) & event;

            Trace("ButtonUp in %d %s:%d\n", xidno, xid[xidno].any.file,
                  xid[xidno].any.line);
            button->type = ButtonRelease;
            button->window = xidno;
            button->x = LOWORD(lParam);
            button->y = HIWORD(lParam);
            button->button = Button2;
            if (win_xevent(event) == -1) {
                WinXExit();
            }
            return (0);
        }
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    case WM_RBUTTONDOWN:
    {
        int xidno = (int) GetWindowWord(hwnd, 0);
        if (xid[xidno].hwnd.event_mask & ButtonPressMask) {
            XEvent event;
            XButtonEvent *button = (XButtonEvent *) & event;
            POINT pt;

            pt.x = LOWORD(lParam);
            pt.y = HIWORD(lParam);
            MapWindowPoints(xid[xidno].hwnd.hWnd, xid[topWindow].hwnd.hWnd,
                            &pt, 1);
            button->type = ButtonPress;
            button->window = xidno;
            button->x = LOWORD(lParam);
            button->y = HIWORD(lParam);
            button->x_root = pt.x;
            button->y_root = pt.y;
            button->button = Button3;
            win_xevent(event);
        }
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    case WM_RBUTTONUP:
    {
        int xidno = (int) GetWindowWord(hwnd, 0);

        if (xid[xidno].hwnd.event_mask & ButtonReleaseMask) {
            XEvent event;
            XButtonEvent *button = (XButtonEvent *) & event;

            Trace("ButtonUp in %d %s:%d\n", xidno, xid[xidno].any.file,
                  xid[xidno].any.line);
            button->type = ButtonRelease;
            button->window = xidno;
            button->x = LOWORD(lParam);
            button->y = HIWORD(lParam);
            button->button = Button3;
            if (win_xevent(event) == -1) {
                WinXExit();
            }
            return (0);
        }
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    case WM_MOUSEMOVE:
    {
        XID xidno = (int) GetWindowWord(hwnd, 0);
        XEvent event;
        XID i;
        XAnyEvent *enter = (XAnyEvent *) & event;

        /* Trace("MouseMove in %d %d/%d %s:%d\n", xidno,
           LOWORD(lParam), HIWORD(lParam), xid[xidno].any.file, xid[xidno].any.line); */

        enter->type = LeaveNotify;
        for (i = 0; i < MAX_XIDS; i++) {
            if (i != xidno && xid[i].type == XIDTYPE_HWND
                    && xid[i].hwnd.mouseover
                    && xid[i].hwnd.event_mask & LeaveWindowMask) {
                Trace("LeaveNotify %d %s:%d\n", xidno,
                      xid[xidno].any.file, xid[xidno].any.line);
                enter->window = i;
                win_xevent(event);
                xid[i].hwnd.mouseover = FALSE;
            }
        }
        if (xid[xidno].hwnd.event_mask & PointerMotionMask) {
            XMotionEvent *me = (XMotionEvent *) & event;
            me->type = MotionNotify;
            me->window = xidno;
            me->x = LOWORD(lParam);
            me->y = HIWORD(lParam);
//                      if (me->x != draw_width/2 && me->y != draw_height/2)
            {
                win_xevent(event);
//                              SetCursorPos(draw_width/2, draw_height/2);
            }
            //      return(0);
        } else if (!xid[xidno].hwnd.mouseover) {
            /* PointerMotionMask is only on captured window *//* so don't do the mouseover event */
            if (xid[xidno].hwnd.event_mask & EnterWindowMask) {
                Trace("EnterNotify %d %s:%d\n", xidno,
                      xid[xidno].any.file, xid[xidno].any.line);
                enter->type = EnterNotify;
                enter->window = xidno;
                win_xevent(event);
            }
            xid[xidno].hwnd.mouseover = TRUE;
        }

        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }

    case WM_ERASEBKGND:
    {
        RECT rect;
        if (GetClientRect(hwnd, &rect)) {
            HDC hBmpDC;
            XID xidno = (int) GetWindowWord(hwnd, 0);
            hBmpDC = xid[xidno].hwnd.hBmpDC;
            if (hBmpDC) {
                Trace("WM_ERASEBKGND %d color=%d %d/%d %d/%d\n", xidno,
                      xid[xidno].hwnd.bgcolor, rect.left, rect.top,
                      rect.right, rect.bottom);
                FillRect(hBmpDC, &rect,
                         (HBRUSH) WinXGetBrush(xid[xidno].hwnd.
                                               bgcolor));
            }
        }
        return (0);
    }
    case WM_PAINT:
    {
        RECT rect;
        if (GetUpdateRect(hwnd, &rect, FALSE)) {
            XID xidno = (int) GetWindowWord(hwnd, 0);
//                      if (xidno == draw)
//                              return DefWindowProc(hwnd, uMsg, wParam, lParam);
            if (xidno >= 0 && xidno < MAX_XIDS) {
                HDC hBmpDC;

                hBmpDC = xid[xidno].hwnd.hBmpDC;
                if (hBmpDC) {
                    PAINTSTRUCT ps;
                    HDC hDC;
                    XEvent event;
                    XExposeEvent *expose = (XExposeEvent *) & event;

                    if (ThreadedDraw && xidno == (int) drawWindow) {
                        ValidateRect(hwnd, &rect);
                        winXTDraw(NULL, xidno, &rect);
                    } else {
                        hDC = BeginPaint(hwnd, &ps);

                        if (xid[xidno].hwnd.event_mask & ExposureMask) {
                            expose->type = Expose;
                            expose->window = xidno;
                            expose->x = rect.left;
                            expose->y = rect.top;
                            expose->width = rect.right - rect.left;
                            expose->height = rect.bottom - rect.top;
                            expose->count = 0;
                            Trace("Expose %d %s:%d\n", xidno,
                                  xid[xidno].any.file,
                                  xid[xidno].any.line);
                            win_xevent(event);
                        }

                        SelectPalette(hDC, myPal, FALSE);
                        RealizePalette(hDC);

                        if (xidno == (int) drawWindow) {
                            //      RECT r;
                            //      WinXUnscaled(hBmpDC);
                            if (ThreadedDraw) {
                                ValidateRect(hwnd, &rect);
                                winXTDraw(hDC, xidno, &rect);
                            } else {
                                BitBlt(hDC, rect.left, rect.top,
                                       rect.right, rect.bottom, hBmpDC,
                                       rect.left, rect.top, SRCCOPY);
                            }
                            //      GetClientRect(hwnd, &r);
                            //      WinXScaled(hBmpDC, r.right - r.left, r.bottom - r.top);
                            drawPending = FALSE;
                        } else {	/* not the main playfield window */
                            BitBlt(hDC, rect.left, rect.top,
                                   rect.right, rect.bottom, hBmpDC,
                                   rect.left, rect.top, SRCCOPY);
                        }
                        EndPaint(hwnd, &ps);
                    }
                    return 0;
                }
            }
        }
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    default:
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    return 0;
}
コード例 #23
0
ファイル: userctrl.cpp プロジェクト: maerson/windbg
LRESULT
CALLBACK
QCQPCtrlWndProc(
                HWND hWnd,
                UINT iMessage,
                WPARAM wParam,
                LPARAM lParam
                )
{
    PAINTSTRUCT     ps ;
//    char            szText [128] ;
    WPARAM          wStyle ;
    RECT            r ;

    wStyle = GetWindowWord (hWnd, CBWNDEXTRA_STYLE) ;
    switch ( iMessage ) {
      case WM_CREATE:
        bTrack = FALSE ;
        break ;

      case WM_PAINT:
        GetClientRect (hWnd, (LPRECT)&r) ;

        BeginPaint (hWnd, &ps) ;

        switch ( wStyle ) {
          case QCQP_CS_PUSHBUTTON:
          case QCQP_CS_LATCHBUTTON:
            DrawBitmapButton (hWnd, (LPRECT)&r) ;
            break ;

          default:
            break ;
        }

        EndPaint (hWnd, &ps) ;
        break ;

      case WM_LBUTTONUP:
        if ( GetWindowWord (hWnd, CBWNDEXTRA_STATE) != STATE_GRAYED ) {
            bTrack = FALSE ;
            ReleaseCapture () ;
            switch (wStyle) {
              case QCQP_CS_PUSHBUTTON:
                // Only change the state and send message back to parent
                // if state is not normal. This prevent user from clicking
                // the mouse on the button then dragging it outside of
                // the button.

                if (GetWindowWord (hWnd, CBWNDEXTRA_STATE) != STATE_NORMAL) {
                    SetWindowWord (hWnd, CBWNDEXTRA_STATE, STATE_NORMAL) ;
                    InvalidateRect (hWnd, (LPRECT)NULL, FALSE) ;

                    // Send information back to where the function key is being
                    // used for the same purpose.

                    SendMessage (GetParent (hWnd),
                          WM_COMMAND,
                          (WPARAM) GetWindowHandle (hWnd, CBWNDEXTRA_MESSAGE),
                          MAKELONG(0, GetDlgCtrlID (hWnd))) ;
                }
                break ;

              case QCQP_CS_LATCHBUTTON:
                if (GetWindowWord (hWnd, CBWNDEXTRA_STATE) != wOldState) {
                    if (wOldState == STATE_NORMAL)
                        SetWindowWord (hWnd, CBWNDEXTRA_STATE, STATE_ON) ;
                    else
                          SetWindowWord (hWnd, CBWNDEXTRA_STATE, STATE_NORMAL) ;

                    InvalidateRect (hWnd, (LPRECT)NULL, FALSE) ;

                    // Send information back to where the function key is being
                    // used for the same purpose.

                    SendMessage (GetParent (hWnd),
                          WM_COMMAND,
                          (WPARAM) GetWindowHandle (hWnd, CBWNDEXTRA_MESSAGE),
                          MAKELONG(0, GetDlgCtrlID (hWnd))) ;
                }
                break ;
            }
        }
        break ;

      case WM_LBUTTONDOWN:
        if ( GetWindowWord (hWnd, CBWNDEXTRA_STATE) != STATE_GRAYED ) {
            bTrack = TRUE ;
            wOldState = GetWindowWord (hWnd, CBWNDEXTRA_STATE) ;
            switch (wStyle) {
              case QCQP_CS_PUSHBUTTON:
              case QCQP_CS_LATCHBUTTON:
                SetWindowWord (hWnd, CBWNDEXTRA_STATE, STATE_PUSHED) ;
                InvalidateRect (hWnd, (LPRECT)NULL, FALSE) ;
                break ;
            }
            SetCapture (hWnd) ;
        }
        break ;

      case WM_MOUSEMOVE:
        if ( GetWindowWord (hWnd, CBWNDEXTRA_STATE) != STATE_GRAYED ) {
            if ( bTrack ) {
                int             x, y ;

                x = LOWORD (lParam) ;   // get x position
                y = HIWORD (lParam) ;   // get y position
                GetClientRect (hWnd, &r) ;

                // if mouse position is outside of button area, bring it
                // back to its old state stored in wOldState.

                if ( ((x < r.left) || (x > r.right)) ||
                    ((y < r.top) || (y > r.bottom)) ) {
                    // redraw the button only if it's not in normal position.
                    if ( GetWindowWord (hWnd, CBWNDEXTRA_STATE) != wOldState ) {
                        SetWindowWord (hWnd, CBWNDEXTRA_STATE, wOldState) ;
                        InvalidateRect (hWnd, (LPRECT)NULL, FALSE) ;
                    }
                } else {
                    // redraw the button only if it's not in pushed position.

                    if ( GetWindowWord (hWnd, CBWNDEXTRA_STATE) != STATE_PUSHED ) {
                        SetWindowWord (hWnd, CBWNDEXTRA_STATE, STATE_PUSHED) ;
                        InvalidateRect (hWnd, (LPRECT)NULL, FALSE) ;
                    }
                }
            }
        }
        break ;

      default:
        return DefWindowProc (hWnd, iMessage, wParam, lParam) ;
        break ;
    }
    return 0L ;
}                                       /* QCQPCtrlWndProc() */
コード例 #24
0
ファイル: dsksheet.c プロジェクト: mingpen/OpenNT
//...................................................................
BOOL OnInitDiskDialog(void)
{
	DWORD					dWord,
							dwResult,
							dwCapacity,
							dwFree,
							dwPercent;
	int						i;
	PeripheralCaps			periphCaps;
	PeripheralMassStorage	periphMS;
	PeripheralDisk			periphDisk;
	TCHAR					str[256],
							buffer[512];
	
	//  Description
	LoadString(hInstance, IDS_DISK_DESC1, buffer, SIZEOF_IN_CHAR(buffer));
	_tcscat(buffer, TEXT("  "));
	LoadString(hInstance, IDS_DISK_DESC2, &(buffer[_tcslen(buffer)]),
				  SIZEOF_IN_CHAR(buffer) - _tcslen(buffer));
	SetDlgItemText(hDisk, IDC_TIP_TEXT, buffer);
	
	dWord = sizeof(periphCaps);
	dwResult = PALGetObject(hPeripheral, OT_PERIPHERAL_CAPABILITIES, 0, &periphCaps,	&dWord);
	if ( dwResult IS RC_SUCCESS )
		{
		if ( ( periphCaps.flags & CAPS_DISK ) AND
		     ( periphCaps.bDisk ) ) {
			// we have a disk, get mass storage object and use disk handle
			dWord = sizeof(PeripheralMassStorage);
			dwResult = PALGetObject(hPeripheral, OT_PERIPHERAL_MASS_STORAGE, 0, &periphMS,	&dWord);
			if ((dwResult IS RC_SUCCESS) AND (periphMS.MScount > 0)) {
				// garth: get the disk handle;  for eclipse there will only be one
				// disk.  Later, there will be more, so will need to make some
				// changes for elkhorn
				for (i = 0; i < (long int) periphMS.MScount; i++) {
					if (periphMS.installed[i].MStype IS MS_DISK) {
						hComponent = periphMS.installed[i].MShandle;
						break;
					}
				}
				dWord = sizeof(PeripheralDisk);
				dwCapacity = 0;
				dwFree = 0;
				dwPercent = 0;
				dwResult = PALGetComponentObject(hPeripheral, hComponent, OT_PERIPHERAL_DISK, 0, &periphDisk,	&dWord);
				if (dwResult IS RC_SUCCESS) {
					if (periphDisk.bInitialized IS TRUE) {
						dwCapacity = (DWORD)(periphDisk.capacity / 1024L);	
						dwFree = (DWORD)(periphDisk.freeSpace / 1024L);	  //use 1024 to mean KBytes on a disk or RAM
						dwPercent = dwFree * 100 / dwCapacity;
					}
				}
				LoadString(hInstance, IDS_TOTAL_SIZE, str, SIZEOF_IN_CHAR(str));
				wsprintf(buffer, str, dwCapacity);
				SetDlgItemText(hDisk, IDC_TOTAL_SIZE, buffer);
				LoadString(hInstance, IDS_FREE_SPACE, str, SIZEOF_IN_CHAR(str));
				wsprintf(buffer, str, dwFree, dwPercent);
				SetDlgItemText(hDisk, IDC_FREE_SPACE, buffer);
				SetWindowWord(GetDlgItem(hDisk, IDC_FREE_SPACE), GWW_TRAYLEVEL, (WORD)dwPercent);
				CheckDlgButton(hDisk, IDC_WRITE_PROTECT, periphDisk.writeProtectStatus == WP_READ);
				CheckDlgButton(hDisk, IDC_FS_INITIALIZED, (BOOL)periphDisk.bInitialized);
				// Set the init check box so that users cannot check/uncheck it
				EnableWindow(GetDlgItem(hDisk, IDC_FS_INITIALIZED), FALSE);
				oldWriteProtect = periphDisk.writeProtectStatus;
				bDiskInitialized = (BOOL)periphDisk.bInitialized;

				// add all of the fonts to the font list box if it has
				// been initialized

				if (periphDisk.bInitialized IS TRUE) {
					GetFontListAndDisplay(hDisk);
				}
				else {
					// no fonts - disable the details and delete buttons
					EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
					EnableWindow(GetDlgItem(hDisk, IDC_FONT_DETAILS), FALSE);
				}
				//----------------get fonts end
				
				//	Depending on current write protect status, enable/disable buttons
				// 	always allow the admin to modify write protect status
				EnableWindow(GetDlgItem(hDisk, IDC_WRITE_PROTECT), TRUE);
				if ( periphDisk.writeProtectStatus IS WP_READ) {
					EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
					EnableWindow(GetDlgItem(hDisk, IDC_INITIALIZE), FALSE);
				}

				// Currently the disk tab only comes up if you have 
				// supervisor access, so enable all buttons, etc	
				// If this is going to change, figure out who gets to delete
				// fonts (admin and user -- how to identify which user you are?

				//if ((dWord = PALModifyAccess(hPeripheral) & SUPERVISOR_ACCESS) {
				//	EnableWindow(GetDlgItem(hDisk, IDC_WRITE_PROTECT), TRUE);
				//	EnableWindow(GetDlgItem(hDisk, IDC_INITIALIZE), TRUE);
				//	EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), TRUE);
				//}
				//else {
				//	EnableWindow(GetDlgItem(hDisk, IDC_WRITE_PROTECT), FALSE);
				//	EnableWindow(GetDlgItem(hDisk, IDC_INITIALIZE), FALSE);
				//	EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
				//}
			} // if MScount > 0

		} // if periphCaps.flags
	}
	return(TRUE);
}
コード例 #25
0
ファイル: dsksheet.c プロジェクト: mingpen/OpenNT
//-------------------------------------------------------------
//	Message cracking functions
//.............................................................
void Cls_OnDiskCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
//	handles WM_COMMAND
{
	DWORD			bufSize,
					dwResult,
					dwCapacity,
//					dwCapBefore,
					dwFree, 
					dwPercent;
	int				ccode;
	TCHAR			str[256];
	TCHAR            title[128];
	TCHAR			buffer[512];
	PeripheralDisk	periphDisk;

	switch(codeNotify)
	{ 
		case LBN_DBLCLK:
			switch (id)
			{
			  case IDC_FONTLIST:
			  	FORWARD_WM_COMMAND(hwnd, IDC_FONT_DETAILS, GetDlgItem(hwnd, IDC_FONT_DETAILS), BN_CLICKED, SendMessage);
			  	break;
			}
			break;

		case BN_CLICKED:
			switch (id)
			{
			  case IDC_INITIALIZE:
				if ( oldWriteProtect IS WP_READ )
				{
					LoadString(hInstance, IDS_INIT_WRITE_PROTECT, str, SIZEOF_IN_CHAR(str));
					LoadString(hInstance, IDS_PRTR_TITLE, title, SIZEOF_IN_CHAR(title));
					ccode = MessageBox(GetParent(hDisk), str, title, MB_OK | MB_ICONEXCLAMATION);
					ccode = IDNO;
				}
				else if ( bDiskInitialized )
				{
					LoadString(hInstance, IDS_INIT_WARNING, str, SIZEOF_IN_CHAR(str));
					LoadString(hInstance, IDS_PRTR_TITLE, title, SIZEOF_IN_CHAR(title));
					ccode = MessageBox(GetParent(hDisk), str, title, MB_YESNO | MB_ICONQUESTION);
				}
				else
				{
					LoadString(hInstance, IDS_INIT_WARNING2, str, SIZEOF_IN_CHAR(str));
					LoadString(hInstance, IDS_PRTR_TITLE, title, SIZEOF_IN_CHAR(title));
					ccode = MessageBox(GetParent(hDisk), str, title, MB_YESNO | MB_ICONQUESTION);
				}
				if ( ccode IS IDYES )
				{ 	//  initialize disk
					HWND	hwndChild;
					periphDisk.flags = 0;
					periphDisk.flags |= SET_INITIALIZE;
					bufSize = sizeof(PeripheralDisk);
					dwResult = PALSetComponentObject(hPeripheral, hComponent, 
						OT_PERIPHERAL_DISK, 0, &periphDisk, &bufSize);
					if (dwResult IS RC_SUCCESS) {

						LoadString(hInstance, IDS_DISK_INIT_SUCCESS, str, SIZEOF_IN_CHAR(str));
						LoadString(hInstance, IDS_PRTR_TITLE, title, SIZEOF_IN_CHAR(title));
						ccode = MessageBox(GetParent(hDisk), str, title, MB_OK);

						if (hwndChild = GetDlgItem(hwnd, IDC_FONTLIST))
						{
							ListBox_ResetContent(hwndChild);
						}
						EnableWindow(GetDlgItem(hDisk, IDC_FONT_DETAILS), FALSE);
						EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
						
						bufSize = sizeof(PeripheralDisk);
						memset(&periphDisk, 0, (size_t)bufSize);
						dwResult = PALGetComponentObject(hPeripheral, hComponent, 
							OT_PERIPHERAL_DISK, 0, &periphDisk, &bufSize);
						if (dwResult IS RC_SUCCESS) {
							dwCapacity = (DWORD)(periphDisk.capacity / 1024L);
							dwFree = (DWORD)(periphDisk.freeSpace / 1024L);
							// the initialize may have been queued and the reported
							// free space may be the old (pre initialize) size.  If
							// so, assume that the file system takes 157 K bytes.
							if (dwFree < dwCapacity - 157) 
								dwFree = dwCapacity - 157;
							dwPercent = dwFree * 100 / dwCapacity;
							LoadString(hInstance, IDS_TOTAL_SIZE, str, SIZEOF_IN_CHAR(str));
							wsprintf(buffer, str, dwCapacity);
							SetDlgItemText(hDisk, IDC_TOTAL_SIZE, buffer);
							LoadString(hInstance, IDS_FREE_SPACE, str, SIZEOF_IN_CHAR(str));
							wsprintf(buffer, str, dwFree, dwPercent);
							SetDlgItemText(hDisk, IDC_FREE_SPACE, buffer);
							SetWindowWord(GetDlgItem(hDisk, IDC_FREE_SPACE), GWW_TRAYLEVEL, (WORD)dwPercent);
							CheckDlgButton(hDisk, IDC_FS_INITIALIZED, TRUE);
							// Set the init check box so that users cannot check/uncheck it
							EnableWindow(GetDlgItem(hDisk, IDC_FS_INITIALIZED), FALSE);
							bDiskInitialized = TRUE;
						}
					}
				}
				break;

			  // If Write Protected was checked and the disk is not write protected
			  // Disable or enable the initialize button
			  // If the disk was write protected leave button disabled until done.
			  case IDC_WRITE_PROTECT:
				if ( oldWriteProtect == WP_READ_WRITE )
				{
			      if ( IsDlgButtonChecked(hDisk, IDC_WRITE_PROTECT) )
			         EnableWindow(GetDlgItem(hDisk, IDC_INITIALIZE), FALSE);
			      else
			         EnableWindow(GetDlgItem(hDisk, IDC_INITIALIZE), TRUE);
				}
				break;


			  case IDC_FONT_DETAILS:
			  {
				DoFontDetails(hwnd,
				             str, sizeof(str),
				             title, sizeof(title));
				break;
			  } // case IDC_FONT_DETAILS:

			  case IDC_FONT_DELETE:
			  {
				DoFontDelete(hwnd,
				             str, sizeof(str),
				             title, sizeof(title));

				bufSize = sizeof(PeripheralDisk);
				memset(&periphDisk, 0, (size_t)bufSize);
				dwResult = PALGetComponentObject(hPeripheral, hComponent, OT_PERIPHERAL_DISK, 0, &periphDisk, &bufSize);
				if (dwResult IS RC_SUCCESS) {
					dwCapacity = (DWORD)(periphDisk.capacity / 1024L);
					dwFree = (DWORD)(periphDisk.freeSpace / 1024L);
					dwPercent = dwFree * 100 / dwCapacity;
					LoadString(hInstance, IDS_FREE_SPACE, str, SIZEOF_IN_CHAR(str));
					wsprintf(buffer, str, dwFree, dwPercent);
					SetDlgItemText(hDisk, IDC_FREE_SPACE, buffer);
					SetWindowWord(GetDlgItem(hDisk, IDC_FREE_SPACE), GWW_TRAYLEVEL, (WORD)dwPercent);
				}

				break;
			  } // case IDC_FONT_DELETE:
			} // case BN_CLICKED:  switch (id)
			break;
	} // switch(codeNotify)
}
コード例 #26
0
inline void SetPointer( HWND hWnd, Window *pWindow )
{
    SetWindowWord( hWnd, 0, (WORD) pWindow );
}
コード例 #27
0
ファイル: userctrl.cpp プロジェクト: maerson/windbg
HWND CreateQCQPWindow(LPSTR lpWindowName,
         DWORD   dwStyle,
         int     x,
         int     y,
         int     dx,
         int     dy,
         HWND    hParent,
         HMENU   hMenu,
         HINSTANCE hInstance,
         WPARAM  wMessage)
{
    HWND hTemp ;
    char szClass[MAX_MSG_TXT] ;
    WORD BaseId = 0;
    WORD State;
    HBITMAP hBitmap;

    Dbg(LoadString(hInstance, SYS_QCQPCtrl_wClass, szClass, MAX_MSG_TXT)) ;
    hTemp = CreateWindow(
          (LPSTR)szClass,            // Window szClass name
          lpWindowName,            // Window's title
          WS_CHILD | WS_VISIBLE,   // window created visible
          x, y,                    // X, Y
          dx, dy,                  // Width, Height of window
          hParent,                 // Parent window's handle
          hMenu,                   // child's id
          hInstance,               // Instance of window
          NULL);                   // Create struct for WM_CREATE

    if (hTemp != NULL) {
        SetWindowWord (hTemp, CBWNDEXTRA_STYLE, LOWORD(dwStyle)) ;
        SetWindowWord (hTemp, CBWNDEXTRA_BITMAP, HIWORD(dwStyle)) ;
        SetWindowWord (hTemp, CBWNDEXTRA_STATE, STATE_NORMAL) ;
        SetWindowHandle (hTemp, CBWNDEXTRA_MESSAGE, wMessage) ;

        if (LOWORD(dwStyle) == QCQP_CS_PUSHBUTTON) {
            // Load the bitmaps and store the handles
            switch (HIWORD(dwStyle)) {
              case IDS_CTRL_TRACENORMAL:
              case IDS_CTRL_TRACEPUSHED:
              case IDS_CTRL_TRACEGRAYED:
                BaseId = VGA_TRACE_NORMAL;
                break;

              case IDS_CTRL_STEPNORMAL:
              case IDS_CTRL_STEPPUSHED:
              case IDS_CTRL_STEPGRAYED:
                BaseId = VGA_STEP_NORMAL;
                break;

              case IDS_CTRL_BREAKNORMAL:
              case IDS_CTRL_BREAKPUSHED:
              case IDS_CTRL_BREAKGRAYED:
                BaseId = VGA_BREAK_NORMAL;
                break;

              case IDS_CTRL_GONORMAL:
              case IDS_CTRL_GOPUSHED:
              case IDS_CTRL_GOGRAYED:
                BaseId = VGA_GO_NORMAL;
                break;

              case IDS_CTRL_HALTNORMAL:
              case IDS_CTRL_HALTPUSHED:
              case IDS_CTRL_HALTGRAYED:
                BaseId = VGA_HALT_NORMAL;
                break;

              case IDS_CTRL_QWATCHNORMAL:
              case IDS_CTRL_QWATCHPUSHED:
              case IDS_CTRL_QWATCHGRAYED:
                BaseId = VGA_QWATCH_NORMAL;
                break;

              case IDS_CTRL_SMODENORMAL:
              case IDS_CTRL_SMODEPUSHED:
              case IDS_CTRL_SMODEGRAYED:
                BaseId = VGA_SMODE_NORMAL;
                break;

              case IDS_CTRL_AMODENORMAL:
              case IDS_CTRL_AMODEPUSHED:
              case IDS_CTRL_AMODEGRAYED:
                BaseId = VGA_AMODE_NORMAL;
                break;


              case IDS_CTRL_FORMATNORMAL:
              case IDS_CTRL_FORMATPUSHED:
              case IDS_CTRL_FORMATGRAYED:
                BaseId = VGA_FORMAT_NORMAL;
                break;


              default:


                Assert(FALSE);
            }

            // Load the bitmaps for each state for the button
            for (State = STATE_NORMAL; State <= STATE_GRAYED; State++) {

                Dbg(hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE( BaseId + State )));

                SetWindowHandle(hTemp, GetBitmapIndex(State), (WPARAM)hBitmap);
            }
        }
    }

    return hTemp ;
}                                       /* CreateQCQPWindow() */
コード例 #28
0
void Hotspot_OnSetState(HWND hWindow, BOOL fState)
/***********************************************************************/
{
	SetWindowWord( hWindow, GWW_STATE, fState );
}
コード例 #29
0
ファイル: resimage.cpp プロジェクト: mingpen/OpenNT
LONG CALLBACK ResultImageWndProc(HWND hWnd, UINT iMsg,
        WPARAM wParam, LPARAM lParam)
{
        UINT            iBmp;
        PAINTSTRUCT     ps;
        HDC             hDC;

        //Handle standard Windows messages.
        switch (iMsg)
        {
                case WM_CREATE:
                        SetWindowWord(hWnd, RIWW_IMAGEINDEX, RESULTIMAGE_NONE);
                        return 0L;

                case WM_PAINT:
                        iBmp = GetWindowWord(hWnd, RIWW_IMAGEINDEX);
                        hDC = BeginPaint(hWnd, &ps);

                        RECT            rc;
                        UINT            x, y;
                        HDC             hDCDlg;
                        HBRUSH          hBr;
                        LOGBRUSH        lb;
                        HWND            hDlg;

                        /*
                         * Our job before using TransparentBlt is to figure out
                         * where to position the result image.  We place it centered
                         * on this control, so get our rect's center and subtract
                         * half of the image dimensions.
                         */
                        GetClientRect(hWnd, &rc);
                        x = (rc.right+rc.left-cxBmpResult)/2;
                        y = (rc.bottom+rc.top-cyBmpResult)/2;

                        // Get the backgroup color the dialog is using.
                        hDlg=GetParent(hWnd);
                        hDCDlg=GetDC(hDlg);
                        hBr = (HBRUSH)SendMessage(hDlg,
                                                                        WM_CTLCOLORDLG,
                                                                        (WPARAM)hDCDlg,
                                                                        (LPARAM)hDlg);
                        ReleaseDC(hDlg, hDCDlg);
                        GetObject(hBr, sizeof(LOGBRUSH), &lb);
                        SetBkColor(hDC, lb.lbColor);


                        if (RESULTIMAGE_NONE != iBmp)
                        {

                            TransparentBlt(hDC, x, y, hBmpResults, iBmp*cxBmpResult, 0,
                                    cxBmpResult, cyBmpResult, RGBTRANSPARENT);
                        }
                        else
                        {
                            FillRect(hDC, &rc, hBr);
                        }
                        EndPaint(hWnd, &ps);
                        break;

                case RIM_IMAGESET:
                        // wParam contains the new index.
                        iBmp=GetWindowWord(hWnd, RIWW_IMAGEINDEX);

                        // Validate the index before changing it and repainting
                        if (RESULTIMAGE_NONE==wParam ||
                                ((RESULTIMAGE_MIN <= wParam) && (RESULTIMAGE_MAX >= wParam)))
                        {
                                SetWindowWord(hWnd, RIWW_IMAGEINDEX, (WORD)wParam);
                                InvalidateRect(hWnd, NULL, FALSE);
                                UpdateWindow(hWnd);
                        }
                        // Return the previous index.
                        return iBmp;

                case RIM_IMAGEGET:
                        // Return the current index.
                        iBmp=GetWindowWord(hWnd, RIWW_IMAGEINDEX);
                        return (LONG)iBmp;

                default:
                        return DefWindowProc(hWnd, iMsg, wParam, lParam);
        }

        return 0L;
}
コード例 #30
0
ファイル: Dialog.c プロジェクト: ErisBlastar/osfree
HWND
InternalCreateDialog(HINSTANCE hInst, LPSTR lpDlg,
                     HWND hWnd, DLGPROC lpFunc, LPARAM lParam)
{
    DIALOGDATA *dp = (DIALOGDATA *) lpDlg;
    CONTROLDATA *cp;
    HWND  	hDlg;
    int     i;
    HWND    hCtl;
    HWND    hFirst = 0,hFirstButton;
    int	X,Y;
    HFONT	hFont = (HFONT)0;
    HFONT	ctlFont;
    DWORD	dwBaseUnits;
    DWORD	dwRet;
    WORD	wDialogWidth, wDialogHeight;
    WORD	wDlgCode;
    int	nWidth, nHeight;
    int	nXBorder = 0, nYBorder = 0;
    int	cyCaption;
    LOGFONT LogFont;
    BOOL	bVisible;
    DWORD	dwStyle;
#if 0
    HDC hDC;
    HCURSOR	hCursOld, hCursHourGlass;
#endif

    dwBaseUnits = GetDialogFontUnits(hFont);
    wDialogWidth  = LOWORD(dwBaseUnits);
    wDialogHeight = HIWORD(dwBaseUnits);

    dwStyle = dp->lStyle;
    /* force WS_POPUP style for top-level dialogs */
    if (!(dwStyle & WS_CHILD))
        dwStyle |= WS_POPUP;

    if (dwStyle & DS_SETFONT  &&
            dp->szFaceName != NULL  && strlen(dp->szFaceName)) {

        memset((LPVOID)&LogFont,0,sizeof(LOGFONT));

        /* dp->wPointSize is defined as the typographical point size,*/
        /*  it must be converted to the logical font size.  */
#if 0
        LogFont.lfHeight = -1 * MulDiv(dp->wPointSize,
                                       GetDeviceCaps (hDC, LOGPIXELSY), 72);
#else
        /* dp->wPointSize is NOT a typographical point size.  It is
         * the font height in dialog base units.  It was misnamed.
         */
        LogFont.lfHeight = (dp->wPointSize * wDialogHeight / 8);
#endif
        LogFont.lfWeight = 700;
        strcpy(LogFont.lfFaceName,dp->szFaceName);

        hFont = CreateFontIndirect(&LogFont);
    }

    /* NOTE:
     *	 the coordinates here are from the resource file
     * 	 we should not change them here, but in Windows.c.
     * 	 this was converted from a straight muliply then
     * 	 divide, to MulDiv, this will round up both the x,y
     *	 and the width.
     */
    X       = MulDiv(dp->x,wDialogWidth,4);
    Y       = MulDiv(dp->y,wDialogHeight,8);
    nWidth  = MulDiv(dp->cx,wDialogWidth,4);
    nHeight = MulDiv(dp->cy,wDialogHeight,8);


    /* final window size and coordinates should be adjusted by */
    /* border and caption size depending on the style	   */

    if (dwStyle & WS_DLGFRAME) {
        nXBorder = GetSystemMetrics(SM_CXDLGFRAME);
        nYBorder = GetSystemMetrics(SM_CYDLGFRAME);
    }
    else if (dwStyle & WS_BORDER) {
        nXBorder = GetSystemMetrics(SM_CXBORDER);
        nYBorder = GetSystemMetrics(SM_CYBORDER);
    }
    if (dwStyle & WS_THICKFRAME) {
        nXBorder = GetSystemMetrics(SM_CXFRAME);
        nYBorder = GetSystemMetrics(SM_CYFRAME);
    }
    X -= nXBorder;
    Y -= nYBorder;
    nWidth += 2*nXBorder;
    nHeight += 2*nYBorder;
    if ((dwStyle & WS_CAPTION) == WS_CAPTION) {
        cyCaption = GetSystemMetrics(SM_CYCAPTION);
        Y -= cyCaption;
        nHeight += cyCaption;
    }

    if (dwStyle & WS_VISIBLE) {
        bVisible = TRUE;
        dwStyle &= ~WS_VISIBLE;
    }
    else
        bVisible = FALSE;

    hDlg = CreateWindow(
               (!HIWORD(dp->szClassName) || !strlen(dp->szClassName))?
               TWIN_DIALOGCLASS:dp->szClassName,
               (HIWORD(dp->szCaption) && strlen(dp->szCaption))?
               dp->szCaption:" ",
               dwStyle,
               X,Y,nWidth,nHeight,
               hWnd,
               (HMENU)0,
               (hInst)?hInst:
               (hWnd?GetWindowInstance(hWnd):0),
               NULL
           );

    if(hDlg == 0) {
        return 0;
    }

    /*
     * The following code was removed because it needlessly leaves
     * an hour glass on all of the applications windows while the dialog
     * box is up.  Another call to SetCursor() was also commented out
     * at the end of this function.
     */
#if 0
    hCursHourGlass = LoadCursor((HINSTANCE)0, IDC_WAIT);
    hCursOld       = SetCursor(hCursHourGlass);
#endif

    SetWF(hDlg,WFDIALOGWINDOW);
    SetWindowWord(hDlg,DWW_STATUS,0);
    SetWindowWord(hDlg,DWW_PARENT,hWnd);
    SetWindowLong(hDlg,DWL_DLGPROC,(LONG)lpFunc);
    SetWindowLong(hDlg,DWL_LPARAM,lParam);
    SetWindowWord(hDlg,DWW_DEFID,(WORD)0L);
    if (hFont)
        SendMessage(hDlg, WM_SETFONT, (WPARAM)hFont,
                    (LPARAM)MAKELONG(FALSE,0));

    for(i=0,cp=dp->controlinfo; i<(int)(dp->bNumberOfItems); i++,cp++) {

        hCtl = CreateWindow(
                   cp->szClass?cp->szClass:"STATIC",
                   ((!cp->szClass || !lstrcmpi(cp->szClass,"STATIC"))
                    && ((cp->lStyle & 0xf) == SS_ICON))?
                   NULL:cp->szText,
                   cp->lStyle,
                   (int)(cp->x*wDialogWidth)/4,
                   (int)(cp->y*wDialogHeight)/8,
                   (int)(cp->cx*wDialogWidth)/4,
                   (int)(cp->cy*wDialogHeight)/8,
                   hDlg,
                   cp->wID,
                   hWnd?GetWindowInstance(hWnd):hInst,
                   NULL
               );
        if(!hFirst && (cp->lStyle & WS_TABSTOP))
            hFirst = hCtl;

        if ((!cp->szClass || !lstrcmpi(cp->szClass,"STATIC")) &&
                ((cp->lStyle & 0xf) == SS_ICON)) {
            /* icon for the SS_ICON control comes from the same place,
            as dialog template, note, only send message if we
            actually have one */
            if(cp->szText)
                SendMessage(hCtl,
                            STM_SETICON,
                            (WPARAM)LoadIcon(hInst,cp->szText),
                            (LPARAM)0);
        }

        /* if a dialog class font was specified, and the control */
        /* has not done a WM_SETFONT, then set this font.        */
        if(hFont) {
            ctlFont = (HFONT)SendMessage(hCtl, WM_GETFONT, 0, 0);
            if(ctlFont == 0)
                SendMessage( hCtl, WM_SETFONT, (WPARAM)hFont,
                             (LPARAM)MAKELONG(FALSE,0) );
        }
    }

    dwRet =  SendMessage(hDlg,WM_INITDIALOG,(WPARAM)hFirst,lParam);

    for (hCtl = GetWindow(hDlg,GW_CHILD),hFirstButton = 0; hCtl;
            hCtl = GetWindow(hCtl,GW_HWNDNEXTSIB)) {
        wDlgCode = (WORD)SendMessage(hCtl,WM_GETDLGCODE,0,0L);
        if (wDlgCode & DLGC_DEFPUSHBUTTON)
            break;
        if ((wDlgCode & DLGC_UNDEFPUSHBUTTON) && (hFirstButton == 0))
            hFirstButton = hCtl;
    }
    if (hCtl != 0)
        SetWindowWord(hDlg,DWW_DEFID,GetWindowID(hCtl));
    else if (hFirstButton != 0)
        SetWindowWord(hDlg,DWW_DEFID,GetWindowID(hFirstButton));
    else
        SetWindowWord(hDlg,DWW_DEFID,0);

    if (dwRet) {
        DlgSetFocus(hFirst);

        if ((WORD)SendMessage(hFirst,WM_GETDLGCODE,0,0L) &
                DLGC_HASSETSEL)
            Edit_SetSel(hFirst, 0, -1);
    }

    hCtl = GetFocus();

    if(hCtl == 0) {
        hCtl = GetFirstDlgTabItem(hDlg);
        if(hCtl) {
            DlgSetFocus(hCtl);

            if ((WORD)SendMessage(hCtl,WM_GETDLGCODE,0,0L) &
                    DLGC_HASSETSEL)
                Edit_SetSel(hCtl, 0, -1);
        }
    }

    if (bVisible) {
        ShowWindow(hDlg,SW_SHOWNORMAL);
    }

    if (bVisible) {
        UpdateWindow(hDlg);
    }

#ifdef CURSORWARPING
    /* this will warp the cursor to the default button */
    /* it only should be activated by a user preference */
    /* and not automatically */
    {
        HWND hWnd;
        int     width ,height;
        RECT rcDlg;

        hWnd = hCtl;
        GetWindowRect(hWnd,&rcDlg);
        width = (rcDlg.left + rcDlg.right)/2;
        height = (rcDlg.bottom + rcDlg.top)/2;
        SetCursorPos(width,height);
    }
#endif

    /* SetCursor(hCursOld); */
    return hDlg;
}