Exemplo n.º 1
0
bool wxTextCtrl::IsEditable() const
{
    if (m_bIsMLE)
        return((bool)LONGFROMMR(::WinSendMsg(GetHwnd(), MLM_QUERYREADONLY, 0, 0)));
    else
        return((bool)LONGFROMMR(::WinSendMsg(GetHwnd(), EM_QUERYREADONLY, 0, 0)));
} // end of wxTextCtrl::IsEditable
Exemplo n.º 2
0
bool wxTextCtrl::IsModified() const
{
    bool                            bRc;

    if (m_bIsMLE)
        bRc = (bool)LONGFROMMR(::WinSendMsg(GetHwnd(), MLM_QUERYCHANGED, 0, 0));
    else
        bRc = (bool)LONGFROMMR(::WinSendMsg(GetHwnd(), EM_QUERYCHANGED, 0, 0));
    return bRc;
} // end of wxTextCtrl::IsModified
Exemplo n.º 3
0
wxString wxNotebook::GetPageText ( size_t nPage ) const
{
    BOOKTEXT                        vBookText;
    wxChar                          zBuf[256];
    wxString                        sStr;
    ULONG                           ulRc;

    wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("notebook page out of range") );

    memset(&vBookText, '\0', sizeof(BOOKTEXT));
    vBookText.textLen = 0; // This will get the length
    ulRc = LONGFROMMR(::WinSendMsg( m_hWnd
                                   ,BKM_QUERYTABTEXT
                                   ,MPFROMLONG((ULONG)m_alPageId[nPage])
                                   ,MPFROMP(&vBookText)
                                  ));
    if (ulRc == (ULONG)BOOKERR_INVALID_PARAMETERS || ulRc == 0L)
    {
        if (ulRc == (ULONG)BOOKERR_INVALID_PARAMETERS)
        {
            wxLogError(wxT("Invalid Page Id for page text querry."));
        }
        return wxEmptyString;
    }
    vBookText.textLen = ulRc + 1; // To get the null terminator
    vBookText.pString = (char*)zBuf;

    //
    // Now get the actual text
    //
    ulRc = LONGFROMMR(::WinSendMsg( m_hWnd
                                   ,BKM_QUERYTABTEXT
                                   ,MPFROMLONG((ULONG)m_alPageId[nPage])
                                   ,MPFROMP(&vBookText)
                                  ));
    if (ulRc == (ULONG)BOOKERR_INVALID_PARAMETERS || ulRc == 0L)
    {
        return wxEmptyString;
    }
    if (ulRc > 255L)
        ulRc = 255L;

    vBookText.pString[ulRc] = '\0';
    sStr = (wxChar*)vBookText.pString;
    return sStr;
} // end of wxNotebook::GetPageText
Exemplo n.º 4
0
bool wxListBox::IsSelected( int N ) const
{
    wxCHECK_MSG( IsValid(N), false,
                 wxT("invalid index in wxListBox::Selected") );

    LONG                            lItem;

    if (GetWindowStyleFlag() & wxLB_EXTENDED)
    {
        if (N == 0)
            lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0));
        else
            lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)(N - 1), (MPARAM)0));
    }
    else
    {
        lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0));
    }
    return (lItem == (LONG)N && lItem != LIT_NONE);
} // end of wxListBox::IsSelected
Exemplo n.º 5
0
long wxComboBox::GetInsertionPoint() const
{
    long                            lPos = LONGFROMMR(::WinSendMsg( GetHwnd()
                                                                   ,LM_QUERYSELECTION
                                                                   ,(MPARAM)0
                                                                   ,(MPARAM)0
                                                                  ));
   if (lPos == LIT_NONE)
        return wxNOT_FOUND;
   return lPos;
} // end of wxComboBox::GetInsertionPoint
Exemplo n.º 6
0
int wxListBox::GetSelection() const
{
    wxCHECK_MSG( !HasMultipleSelection(),
                 -1,
                 wxT("GetSelection() can't be used with multiple-selection "
                    "listboxes, use GetSelections() instead.") );

    return(LONGFROMMR(::WinSendMsg( GetHwnd()
                                   ,LM_QUERYSELECTION
                                   ,(MPARAM)LIT_FIRST
                                   ,(MPARAM)0
                                  )
                     ));
} // end of wxListBox::GetSelection
Exemplo n.º 7
0
int wxChoice::FindString(
  const wxString&                   rsStr
) const
{
    int                             nPos;
    int                             nTextLength;
    PSZ                             zStr;
    int                             nItemCount;

    nItemCount = (int)LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMCOUNT, (MPARAM)0, (MPARAM)0));
    for (nPos = 0; nPos < nItemCount; nPos++)
    {
        nTextLength = (int)LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)nPos, (MPARAM)0));
        zStr = new char[nTextLength + 1];
        ::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT)nPos, (SHORT)nTextLength), (MPARAM)zStr);
        if (rsStr == (wxChar*)zStr)
        {
            delete [] zStr;
            break;
        }
        delete [] zStr;
    }
    return nPos;
} // end of wxChoice::FindString
Exemplo n.º 8
0
BOOL InitVolume(HWND hwndDlg)
{
    WNDPARAMS WndParams;
    SLDCDATA SliderData;
    BOOL bResult;

    hwndVolumeLeft = WinWindowFromID(hwndDlg, ID_VOLUME_LEFT);
    hwndVolumeRight = WinWindowFromID(hwndDlg, ID_VOLUME_RIGHT);
    hwndChannelIndependent = WinWindowFromID(hwndDlg, ID_CHANNEL_INDEPENDENT);
    hwndChannelSwap = WinWindowFromID(hwndDlg, ID_CHANNEL_SWAP);
    hwndMute = WinWindowFromID(hwndDlg, ID_MUTE);

    VolSliderPixels = SHORT2FROMMR(WinSendMsg(hwndVolumeLeft, SLM_QUERYSLIDERINFO,
        MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE), NULL));
    WndParams.fsStatus = WPM_CTLDATA;
    WndParams.cbCtlData = sizeof(SLDCDATA);
    WndParams.pCtlData = &SliderData;
    SliderData.cbSize = sizeof(SLDCDATA);
    SliderData.usScale1Increments = VolSliderPixels;
    SliderData.usScale2Increments = VolSliderPixels;
    SliderData.usScale1Spacing = 1;
    SliderData.usScale2Spacing = 1;
    bResult = LONGFROMMR(WinSendMsg(hwndVolumeLeft, WM_SETWINDOWPARAMS,
        MPFROMP(&WndParams), NULL));
    bResult = LONGFROMMR(WinSendMsg(hwndVolumeRight, WM_SETWINDOWPARAMS,
        MPFROMP(&WndParams), NULL));

    WinSendMsg(hwndMute, GBM_SETBITMAPINDEX, MPFROMSHORT(GB_DISABLE),
        MPFROMSHORT(1));
    WinSendMsg(hwndMute, GBM_SETBITMAPINDEX, MPFROMSHORT(GB_DOWN),
        MPFROMSHORT(2));

    VolChannelSwap = FALSE;

    return TRUE;
}
Exemplo n.º 9
0
unsigned int OS2Popup::findInsertionPoint( unsigned int pos ) const
{
    int nCount = LONGFROMMR( WinSendMsg( m_hMenu, MM_QUERYITEMCOUNT, 0, 0 ));

    // For this simple algorithm, we rely on the fact that in the final state
    // of the menu, the ID of each item is equal to its position in the menu
    int i = 0;
    while( i < nCount &&
           SHORT1FROMMR( WinSendMsg( m_hMenu, MM_ITEMIDFROMPOSITION,
                                     MPFROMLONG( i ), 0 )) < pos )
    {
        i++;
    }
    return i;
}
Exemplo n.º 10
0
wxString wxListBox::GetString(unsigned int n) const
{
    LONG     lLen = 0;
    wxChar*  zBuf;
    wxString sResult;

    wxCHECK_MSG( IsValid(n), wxEmptyString,
                 wxT("invalid index in wxListBox::GetClientData") );

    lLen = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)n, (MPARAM)0));
    zBuf = new wxChar[lLen + 1];
    ::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT)n, (SHORT)lLen), (MPARAM)zBuf);
    zBuf[lLen] = '\0';
    sResult = zBuf;
    delete [] zBuf;
    return sResult;
} // end of wxListBox::GetString
Exemplo n.º 11
0
wxString wxChoice::GetString(unsigned int n) const
{
    int      nLen = 0;
    wxString sStr = wxEmptyString;
    wxChar*  zBuf;

    nLen = (size_t)LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)n, (MPARAM)0));
    if (nLen != LIT_ERROR && nLen > 0)
    {
        zBuf = new wxChar[++nLen];
        ::WinSendMsg( GetHwnd()
                     ,LM_QUERYITEMTEXT
                     ,MPFROM2SHORT((SHORT)n, (SHORT)nLen)
                     ,(MPARAM)zBuf
                    );
        sStr = zBuf;
        delete [] zBuf;
    }
    return sStr;
} // end of wxChoice::GetString
Exemplo n.º 12
0
int wxListBox::FindString(
  const wxString&                   rsString
) const
{
    int                             nPos;
    LONG                            lTextLength;
    PSZ                             zStr;


    for (nPos = 0; nPos < m_nNumItems; nPos++)
    {
        lTextLength = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)nPos, (MPARAM)0));
        zStr = new char[lTextLength + 1];
        ::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT(nPos, (SHORT)lTextLength), (MPARAM)zStr);
        if (rsString == (wxChar*)zStr)
        {
            delete [] zStr;
            break;
        }
        delete [] zStr;
    }
    return nPos;
} // end of wxListBox::FindString
Exemplo n.º 13
0
int wxChoice::GetSelection() const
{
    return((int)LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0)));
} // end of wxChoice::GetSelection
Exemplo n.º 14
0
// *******************************************************************************
// FUNCTION:     wm_command
//
// FUNCTION USE: Process WM_COMMAND messages for the dialog window
//
// DESCRIPTION:  If the OK button is clicked, retrieve information from the
//               dialog to set the new margin values.
//
// PARAMETERS:   HWND     dialog window handle
//               MPARAM   first message parameter
//               MPARAM   second message parameter
//
// RETURNS:      MRESULT  Reserved value of zero
//
// INTERNALS:    NONE
//
// *******************************************************************************
static MRESULT wm_command( HWND hwnd, MPARAM mp1, MPARAM mp2 )
{
   PSETFORM    pSetForm;

   switch (SHORT1FROMMP(mp1)) {
   case DID_OK:
// --------------------------------------------------------------------------
// User pressed the OK button - get the data pointer from instance data
// --------------------------------------------------------------------------
      pSetForm = (PSETFORM)WinQueryWindowULong( hwnd, QWL_USER );

// --------------------------------------------------------------------------
// get the selected units
// --------------------------------------------------------------------------
      pSetForm->ulUnits = (ULONG)LONGFROMMR(WinSendDlgItemMsg( hwnd,
                           CID_MEASURE, VM_QUERYSELECTEDITEM, 0L, 0L ) );

// --------------------------------------------------------------------------
// Get new margin values from the entry fields
// --------------------------------------------------------------------------
      GetEntryField( hwnd, CID_MAR_LEFT,
                     &pSetForm->rectlMargins.xLeft, pSetForm->ulUnits );
      GetEntryField( hwnd, CID_MAR_TOP,
                     &pSetForm->rectlMargins.yTop, pSetForm->ulUnits );
      GetEntryField( hwnd, CID_MAR_RIGHT,
                     &pSetForm->rectlMargins.xRight, pSetForm->ulUnits );
      GetEntryField( hwnd, CID_MAR_BOTTOM,
                     &pSetForm->rectlMargins.yBottom, pSetForm->ulUnits );

// --------------------------------------------------------------------------
// convert rectangle from current unit of measure to LO_METRIC */
// --------------------------------------------------------------------------
      if (pSetForm->ulUnits == (ULONG)VSI_INCHES) {
         pSetForm->rectlMargins.xLeft =
                                   HINTOLM( pSetForm->rectlMargins.xLeft );
         pSetForm->rectlMargins.xRight =
                                   HINTOLM( pSetForm->rectlMargins.xRight );
         pSetForm->rectlMargins.yTop =
                                   HINTOLM( pSetForm->rectlMargins.yTop );
         pSetForm->rectlMargins.yBottom =
                                   HINTOLM( pSetForm->rectlMargins.yBottom );
      } else if (pSetForm->ulUnits == (ULONG)VSI_POINTS ) {
         pSetForm->rectlMargins.xLeft =
                                   PTSTOLM( pSetForm->rectlMargins.xLeft );
         pSetForm->rectlMargins.xRight =
                                   PTSTOLM( pSetForm->rectlMargins.xRight );
         pSetForm->rectlMargins.yTop =
                                   PTSTOLM( pSetForm->rectlMargins.yTop );
         pSetForm->rectlMargins.yBottom =
                                   PTSTOLM( pSetForm->rectlMargins.yBottom );
      } else {
         pSetForm->rectlMargins.xLeft =
                                   MMTOLM( pSetForm->rectlMargins.xLeft );
         pSetForm->rectlMargins.xRight =
                                   MMTOLM( pSetForm->rectlMargins.xRight );
         pSetForm->rectlMargins.yTop =
                                   MMTOLM( pSetForm->rectlMargins.yTop );
         pSetForm->rectlMargins.yBottom =
                                   MMTOLM( pSetForm->rectlMargins.yBottom );
      } /* endif */

// --------------------------------------------------------------------------
// Indicate successful completion
// --------------------------------------------------------------------------
      WinDismissDlg( hwnd, TRUE );

// --------------------------------------------------------------------------
// return appropriate value
// --------------------------------------------------------------------------
      return (MRESULT)0L;

   case DID_CANCEL:
// --------------------------------------------------------------------------
// CANCEL pressed - indicate unsuccessful completion.
// --------------------------------------------------------------------------
      WinDismissDlg( hwnd, FALSE );

// --------------------------------------------------------------------------
// return appropriate value
// --------------------------------------------------------------------------
      return (MRESULT)0L;

   default:
      return WinDefDlgProc( hwnd, WM_COMMAND, mp1, mp2 );
   } /* endswitch */
}
Exemplo n.º 15
0
MRESULT	EXPENTRY DriverWndProc(HWND hWnd, ULONG	msg, MPARAM mp1, MPARAM	mp2)

{
CHAR	     szFile[CCHMAXPATH];   /* File HOlder			*/
FILEFINDBUF3 findbuf;		   /* File Find	Buffer			*/
FONTMETRICS  fm;		   /* Font Metrics Structure		*/
HDIR	     hDir = (HDIR)HDIR_CREATE; /* Directory Handle		*/
HPS	     hPS;		   /* Presentation Space Handle		*/
HWND	     hwndListBox;	   /* List Box Window Handle		*/
LISTBOXCDATA lbwcd;		   /* List Box Window Control Data	*/
POWNERITEM   poi;		   /* Owner Item			*/
RECTL	     rcl;		   /* Client Window Rectangle		*/
ULONG	     ulFileCnt = 1UL;	   /* File Counter Holder		*/
register INT i,	k, n;		   /* Loop Counter			*/

switch ( msg )
   {
		       /* Perform window initialization			*/
   case	WM_CREATE :
       hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW,	FALSE);
       WinSetPointer(HWND_DESKTOP, hptrWait = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
       memset(&lbwcd, 0, sizeof(LISTBOXCDATA));
       lbwcd.cb	= sizeof(LISTBOXCDATA);
       lbwcd.ulVersion = LBV_110;
       lbwcd.vdata.lbcd1_1.flExtStyles = LSXS_CHECKBOX | LSXS_EDITABLE;

       hwndList1 = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE,
				   10L,	10L, 100L, 175L, hWnd,
				   HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL);

       hwndListx = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE,
				   125L, 10L, 100L, 175L, hWnd,
				   HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL);

       hwndList2 = WinCreateWindow(hWnd, "ListBoxWindow", "", WS_VISIBLE, 10L, 190L, 250L, 200L, hWnd,
				   HWND_TOP, 1025UL, (PVOID)&lbwcd, (PVOID)NULL);

       WinSendMsg(hwndList1, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_SINGLECLICK),
		  MPFROMP("ahooga.wav"));
       WinSendMsg(hwndListx, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_DOUBLECLICK),
		  MPFROMP("flush.wav"));

       hwndListA = WinCreateWindow(hWnd, WC_LISTBOX, "", LS_OWNERDRAW |	LS_HORZSCROLL |	LS_MULTIPLESEL | WS_VISIBLE,
				   275L, 10L, 100L, 175L, hWnd,
				   HWND_TOP, 1026UL, (PVOID)NULL, (PVOID)NULL);

		       /* Sub-class the	default	window procedure with	*/
		       /* new one which	will handle specific messages	*/
		       /* allowing better control over the sizing frame	*/

       hwndListB = WinCreateWindow(hWnd, WC_LISTBOX, "", WS_VISIBLE | LS_EXTENDEDSEL, 275L, 190L, 250L,	200L, hWnd,
				   HWND_TOP, 1027UL, (PVOID)NULL, (PVOID)NULL);

       for ( i = 0; i <	10; i++	)
	   {
	   sprintf(szFile, "Item %04d Item %04d Item %04d", i, i, i);
	       WinSendMsg(hwndListx, LM_INSERTITEM,
			  MPFROMLONG(LIT_END),
			  MPFROMP(szFile));
	   }

       n = (INT)WinSendMsg(hwndList2, LMX_CALCLINECOUNT, MPFROMLONG(175L), 0L);

       k = 0;

       WinSendMsg(hwndList2, LM_SETITEMHEIGHT, MPFROMLONG(36L),	0L);

       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       WinSendMsg(hwndList2, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTDESCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndList1, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       if ( ++k	> n )
		   WinSendMsg(hwndList2, LM_SETTOPINDEX, MPFROMLONG(k -	n), 0L);
	       WinSendMsg(hwndListB, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTDESCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndListA, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }
       break;

   case	WM_BUTTON1DOWN :
       WinEnableWindowUpdate(hwndListA,	FALSE);
       WinEnableWindowUpdate(hwndList1,	FALSE);

       WinSendMsg(hwndListA, LM_DELETEALL, 0L, 0L);
       WinSendMsg(hwndList1, LM_DELETEALL, 0L, 0L);
       i = 0;
       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       WinSendMsg(hwndListA, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndList1, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       ++i;
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }
       WinShowWindow(hwndListA,	TRUE);
       WinShowWindow(hwndList1,	TRUE);

       while ( i )
	   {
	   if (	i % 2 )
	       {
	       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE));
	       WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE));
	       }
	   --i;
	   }
       break;

   case	WM_CONTROL :
       switch (	SHORT2FROMMP(mp1) )
	   {
		       /* Process double click on a List Box		*/

	   case	LN_SELECT :
	       switch (	SHORT1FROMMP(mp1) )
		   {
		   case	1024UL :
		   /*  WinAlarm(HWND_DESKTOP, WA_NOTE);	  */
		       break;

		   case	1027UL :
		   /*  WinAlarm(HWND_DESKTOP, WA_ERROR);  */
		       break;
		   }
	       break;
	   }
       break;


   case	WM_MEASUREITEM :
       GpiQueryFontMetrics(hPS = WinGetPS(hWnd), sizeof(FONTMETRICS), &fm);
       WinReleasePS(hPS);
       return(MRFROMLONG(fm.lMaxBaselineExt));

		       /* Draw a list box item				*/
   case	WM_DRAWITEM :

       if ( SHORT1FROMMP(mp1) == 1024 )
	   hwndListBox = hwndList1;
       else
	   if (	SHORT1FROMMP(mp1) == 1026 )
	       hwndListBox = hwndListA;

		       /* Point	to Owner Item information		*/

       poi = (POWNERITEM)mp2;
       GpiCreateLogColorTable(poi->hps,	0L, LCOLF_RGB, 0L, 0L, (PLONG)NULL);

       i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXTLENGTH,
				      MPFROMLONG(poi->idItem), 0L));

       i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXT,
				      MPFROM2SHORT(poi->idItem,	CCHMAXPATH),
				      MPFROMP(szFile)));

		       /* Check	to see if item to be drawn or		*/
		       /* highlighted					*/

       if ( poi->fsState != poi->fsStateOld )
	   {
	   WinFillRect(poi->hps, &poi->rclItem,	RGBCLR_DIALOGBACKGROUND);

	   if (	poi->fsState )
	       WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
			   RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER |
			   DT_ERASERECT);

		       /* Set item highlighting	by inverting the items	*/
		       /* rectangle colour				*/

	   WinInvertRect(poi->hps, &poi->rclItem);

	   if (	!poi->fsState )
	       WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
			   RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER |
			   DT_ERASERECT);
	   poi->fsState	= poi->fsStateOld = 0;
	   }
       else
	   {
		       /* Item needs to	be drawn, get item rectangle	*/
		       /* item position					*/

	   WinFillRect(poi->hps, &poi->rclItem,	RGBCLR_DIALOGBACKGROUND);

	   WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
		       RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER	|
		       DT_ERASERECT);
	   }
       return(MRFROMLONG(TRUE));

   case	WM_BUTTON1DBLCLK :
       i = 0;
       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       ++i;
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }

       while ( i )
	   {
	   if (	i % 2 )
	       {
	       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE));
	       WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE));
	       }
	   --i;
	   }
       break;

   case	WM_BUTTON2DOWN :

       for ( i = 0; i <	5; i++ )
	   WinSendMsg(hwndListx, LM_DELETEITEM,	MPFROMSHORT(2),	0L);

#if 0
       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(LIT_NONE), MPFROMLONG(TRUE));

       i = LIT_FIRST;
       while ( (i = (INT)LONGFROMMR(WinSendMsg(hwndList1, LM_QUERYSELECTION, MPFROMLONG(i), 0L))) != LIT_NONE )
	   WinSendMsg(hwndList1, LM_SELECTITEM,	MPFROMLONG(i), MPFROMLONG(FALSE));
#endif
       break;
		       /* Erase	background				*/

   case	WM_ERASEBACKGROUND :
       WinQueryWindowRect(hWnd,	&rcl);
       WinFillRect((HPS)mp1, &rcl, SYSCLR_DIALOGBACKGROUND);
       break;
		       /* Paint	the main client	window			*/
   case	WM_PAINT :
       WinSetPointer(HWND_DESKTOP, hptrWait);

       WinFillRect(hPS = WinBeginPaint(hWnd, (HPS)NULL,	&rcl), &rcl, SYSCLR_DIALOGBACKGROUND);

       WinEndPaint(hPS);
       WinSetPointer(HWND_DESKTOP, hptrArrow);
       break;
		       /* Close	Down					*/
   case	WM_CLOSE :

       WinPostMsg(hWnd,	WM_QUIT, 0L, 0L);
       break;

   case	WM_DESTROY :
       WinDestroyPointer(hptrArrow);
       WinDestroyPointer(hptrWait);
       break;
		       /* Default message processing			*/
   default:
       return(WinDefWindowProc(hWnd, msg, mp1, mp2));
   }
return(0L);
}
Exemplo n.º 16
0
MRESULT EXPENTRY MLECustomProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
{
SHORT sScrollBarFirst;
SHORT sScrollBarLast;
static SHORT sScrollBarRange;
USHORT idVScroll;
USHORT idHScroll;
static int iFirstVScroll=0;
static int iFirstHScroll=0;
static HWND hwndHScroll;
static HWND hwndVScroll;
MRESULT mres;
IPT ipt;                //Insertion point
IPT iptLineStart;       //First insertion point for a line
IPT iptTotalLineLength; //Total lenght of a line of text
IPT iptCursorToEndLength; //Length from cursor to end of line.
static long lCurrentLine;
static long lCurrentColumn;
int iRes;
static BOOL bEnterKeyDown;
LONG lColor;

switch(msg)
        {

        case MLM_SETFONT:
            FontPalProc();    
        break;
        case MLM_SETBACKCOLOR:

        WinDlgBox(HWND_DESKTOP, hwnd, ColorChgDlgProc,
            NULLHANDLE, IDD_COLORCHANGE, NULL);

        //Reshow color palette
        ColorPalProc();
        
        //If background color is changed, let message fall through
        if(glColorChgAction==COLORCHANGE_BACKGROUND)
            {
            //Get color of text.
            lColor=LONGFROMMR(WinSendMsg(hwndMLE, MLM_QUERYTEXTCOLOR,
                                                    MPVOID,MPVOID));
            if(lColor==mp1)
                {
                sprintf(buffer,"Text color and background color may not be the same.");
                WinMessageBox(HWND_DESKTOP, hwndClient, buffer,szAppName,0,
                                    MB_OK|MB_ICONEXCLAMATION|MB_MOVEABLE);
                return 0;
                }
            else
                {
                //Set color change flag so color is not changed again.
                glColorChgAction=COLORCHANGE_CANCEL;

                break;
                }
            }

        //If text color is changed, change text color and return
        if(glColorChgAction==COLORCHANGE_TEXT)
            {
            //Get color of background.
            lColor=LONGFROMMR(WinSendMsg(hwndMLE, MLM_QUERYBACKCOLOR,
                                                    MPVOID,MPVOID));
            if(lColor==mp1)
                {
                sprintf(buffer,"Text color and background color may not be the same.");
                WinMessageBox(HWND_DESKTOP, hwndClient, buffer,szAppName,0,
                                    MB_OK|MB_ICONEXCLAMATION|MB_MOVEABLE);
                return 0;
                }
            else
                {
                WinSendMsg(hwndMLE, MLM_SETTEXTCOLOR, mp1, MPVOID);
                //Set color change flag so color is not changed again.
                glColorChgAction=COLORCHANGE_CANCEL;
                return 0;
                }
            
            }
        
        //Handle cancel
        if(glColorChgAction==COLORCHANGE_CANCEL) return 0;

        
        break; //MLM_SETBACKCOLOR

        case WM_CHAR:

             //Set enter key flag down for autoindent.   
             if(!(CHARMSG(&msg)->fs & KC_KEYUP))
                {
                switch(CHARMSG(&msg)->vkey)
                    {
                    case VK_ENTER:
                    case VK_NEWLINE:
                    bEnterKeyDown=TRUE;
                    break;
                    }                    
                }

             //Let autosave know there was a modification
              if(CHARMSG(&msg)->fs & KC_KEYUP)
                {
                iRes=AutoSaveModProc(AUTOSAVEMOD_INCREMENT);
                }  

             //Handle key status changes - caps lock, num lock, insert
             if(CHARMSG(&msg)->fs & KC_KEYUP)
             if(CHARMSG(&msg)->fs & KC_VIRTUALKEY)
                switch(CHARMSG(&msg)->vkey)
                {

                case VK_PAGEUP:
                break;
                case VK_UP:
                break;

                case VK_ENTER:
                case VK_NEWLINE:
                    if(bEnterKeyDown)
                    {
                        if(bUseAutoIndent)
                        iRes=AutoIndentProc();
                    }
                bEnterKeyDown=FALSE;    
                break;
                

                case VK_INSERT:
                case VK_CAPSLOCK:
                case VK_NUMLOCK:
                        if (bStatusBarOn) UpdateKeyStatus(); //in status.c
                break;
                }
                

        case WM_BUTTON1CLICK:
                if (bStatusBarOn)
                {

                //Update line display in status window
                ipt=LONGFROMMR(WinSendMsg(hwndMLE,
                        MLM_QUERYSEL,
                        MPFROMSHORT(MLFQS_CURSORSEL),
                        MPVOID));
                lGlobalCurrentLine=LONGFROMMR(WinSendMsg(hwndMLE,
                                                MLM_LINEFROMCHAR,
                                                MPFROMLONG(ipt),
                                                MPVOID))+1;
                //Get start of current line
                iptLineStart=LONGFROMMR(WinSendMsg(hwndMLE,
                        MLM_CHARFROMLINE,
                        MPFROMLONG(-1L),
                        //MPFROMLONG(lGlobalCurrentLine),
                        MPVOID));

                //Get total length of line
                iptTotalLineLength=LONGFROMMR(WinSendMsg(hwndMLE,
                        MLM_QUERYLINELENGTH,
                        MPFROMLONG(iptLineStart),
                        MPVOID));
 
                //Get length from cursor to end of line
                iptCursorToEndLength=LONGFROMMR(WinSendMsg(hwndMLE,
                        MLM_QUERYLINELENGTH,
                        MPFROMLONG(-1L),
                        MPVOID));

                //Calculate current column
                lGlobalCurrentColumn=iptTotalLineLength-iptCursorToEndLength+1;
 
                //Update status window if line or column has changed
                if (
                   (lCurrentColumn!=lGlobalCurrentColumn) ||
                   (lCurrentLine!=lGlobalCurrentLine)
                   ) UpdateStatusWindow();

                //store curren line and column
                lCurrentColumn=lGlobalCurrentColumn;
                lCurrentLine=lGlobalCurrentLine;

                } //end if bStatusBarOn

        break;

        /////////////////////////////////////////////////////
        //Real-time vertical scrolling
        case WM_VSCROLL:

            if(iFirstVScroll==0)
                {
                //Get scroll bar ID
                idVScroll=SHORT1FROMMP(mp1);

                //Get handle of scroll vertical scroll bar.
                hwndVScroll=WinWindowFromID(hwndMLE,idVScroll);
 
                //Get scroll bar range.
                mres=WinSendMsg(hwndVScroll,
                        SBM_QUERYRANGE,
                        MPVOID,MPVOID);

                sScrollBarFirst=SHORT1FROMMR(mres);
                sScrollBarLast=SHORT2FROMMR(mres);
                sScrollBarRange=sScrollBarLast-sScrollBarFirst;

                iFirstVScroll=1;

                }

            if (SHORT2FROMMP(mp2)==SB_ENDSCROLL) break;

            switch (SHORT2FROMMP(mp2))
                {

                case SB_SLIDERTRACK:
                //Send message to fool MLE into thinking scroll has ended
                WinSendMsg(hwndMLE,
                        WM_VSCROLL,
                        mp1,
                        MPFROMLONG(
                                MAKELONG(
                                            SHORT1FROMMP(mp2),
                                            SB_SLIDERPOSITION
                                            )
                                        ));

                WinSendMsg(hwndMLE,
                        WM_VSCROLL,
                        mp1,
                        MPFROMLONG(
                                MAKELONG(
                                            SHORT1FROMMP(mp2),
                                            SB_ENDSCROLL
                                            )
                                        ));

                    
                break;


                 }

        //Invalidate scroll paint area.
        WinInvalidateRect(hwndVScroll,NULL,TRUE);

        //Force update of scroll bar
        WinUpdateWindow(hwndVScroll);

        break;//WM_VSCROLL
        /////////////////////////////////////////////////////

        /////////////////////////////////////////////////////
        //Real-time horizontal scrolling.
        case WM_HSCROLL:
            if(iFirstHScroll==0)
                {
                //Get scroll bar ID
                idHScroll=SHORT1FROMMP(mp1);

                //Get handle of scroll vertical scroll bar.
                hwndHScroll=WinWindowFromID(hwndMLE,idHScroll);
 
                iFirstHScroll=1;
    
                }

            if (SHORT2FROMMP(mp2)==SB_ENDSCROLL) break;
            

            switch (SHORT2FROMMP(mp2))
                {
                case SB_SLIDERTRACK:
                //Send message to fool MLE into thinking scroll has ended
                WinSendMsg(hwndMLE,
                         WM_HSCROLL,
                         mp1,
                        MPFROMLONG(
                                MAKELONG(
                                            SHORT1FROMMP(mp2),
                                            SB_SLIDERPOSITION
                                            )
                                        ));

                WinSendMsg(hwndMLE,
                         WM_HSCROLL,
                         mp1,
                        MPFROMLONG(
                                MAKELONG(
                                            SHORT1FROMMP(mp2),
                                            SB_ENDSCROLL
                                            )
                                        ));
                    
                break;
                }
        //Invalidate scroll paint area.
        WinInvalidateRect(hwndHScroll,NULL,TRUE);

        //Force update of scroll bar
        WinUpdateWindow(hwndHScroll);

            
        break; //WM_HSCROLL
        /////////////////////////////////////////////////////

        }

return MLEDefProc(hwnd,msg,mp1,mp2);
}
Exemplo n.º 17
0
MRESULT	EXPENTRY PrnSetupDlgProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)

{
CHAR szPrinter[CCHMAXPATH];	   /* Printer Name Holder		*/
PPRN pprn;			   /* Printer List Pointer		*/
register INT i,	n;		   /* Loop Counters			*/

switch ( msg )
   {
   case	WM_INITDLG :
		       /* Save the pointer to user style information	*/
		       /* within the dialog's reserved memory           */

       WinSetWindowPtr(hWnd, QWL_USER, (PVOID)(pprn = (PPRN)mp2));

		       /* Go through the queue list and	add each of the	*/
		       /* queue	entries	to the list box	from which the	*/
		       /* user can select a printer to use and/or	*/
		       /* configure					*/

       for ( i = 0; i <	pprn->cQueues; i++ )
	   {
		       /* Insert item and store	index			*/

	   WinSendDlgItemMsg(hWnd, LB_PRINTERS,	LM_SETITEMHANDLE,
			     MPFROMSHORT(n = (INT)LONGFROMMR(WinSendDlgItemMsg(hWnd, LB_PRINTERS, LM_INSERTITEM,
									       MPFROMSHORT(LIT_SORTASCENDING),
									       MPFROMP(strcat(strcat(strcpy(szPrinter,
										       pprn->pquei[i].pszName),	": "),
										       pprn->pquei[i].pszDriverName))))),
			     MPFROMP(i));

		       /* If the default printer, save the name	to set	*/
		       /* selection					*/

	   if (	i == pprn->iQueue )
	       WinSendDlgItemMsg(hWnd, LB_PRINTERS, LM_SELECTITEM, MPFROMSHORT(n), MPFROMSHORT(TRUE));
	   }
       CenterDlg(hWnd);
       break;
		       /* Process list box selections			*/
   case	WM_CONTROL :
       switch (	SHORT2FROMMP(mp1) )
	   {
		       /* Printer entry	selected			*/

	   case	LN_SELECT :
	       WinEnableWindow(WinWindowFromID(hWnd, DID_SETUP), TRUE);
	       WinEnableWindow(WinWindowFromID(hWnd, DID_OK),	 TRUE);
	       break;
	   }
       break;

   case	WM_COMMAND :
       switch (	SHORT1FROMMP(mp1) )
	   {
	   case	DID_OK :
		       /* Get selection	from the list box		*/

	       pprn = (PPRN)WinQueryWindowPtr(hWnd, QWL_USER);

		       /* Get printer handle				*/

	       pprn->iQueue = (INT)LONGFROMMR(WinSendDlgItemMsg(hWnd, LB_PRINTERS, LM_QUERYITEMHANDLE,
								MPFROMLONG(WinSendDlgItemMsg(hWnd, LB_PRINTERS,
											     LM_QUERYSELECTION,
											     0L, 0L)),
								0L));
	       WinDismissDlg(hWnd, TRUE);
	       break;

	   case	DID_SETUP :

		       /* Get printer handle				*/

	       PrnQueryJobProperties((PPRN)WinQueryWindowPtr(hWnd, QWL_USER),
				     (INT)LONGFROMMR(WinSendDlgItemMsg(hWnd,
								       LB_PRINTERS,
								       LM_QUERYITEMHANDLE,
								       MPFROMLONG(WinSendDlgItemMsg(hWnd,
												    LB_PRINTERS,
												    LM_QUERYSELECTION,
												    0L,	0L)),
								       0L)));
	       break;

	   case	DID_CANCEL :
	       WinDismissDlg(hWnd, FALSE);
	       break;
	   }
       break;
		       /* Close	received, exit dialog			*/
   case	WM_CLOSE :
       WinDismissDlg(hWnd, FALSE);
       break;

   default :
       return(WinDefDlgProc(hWnd, msg, mp1, mp2));
   }
		       /* Pass through unhandled messages		*/
return(0L);
}
Exemplo n.º 18
0
int wxListBox::GetSelections( wxArrayInt& raSelections ) const
{
    int                             nCount = 0;
    LONG                            lItem;


    raSelections.Empty();
    if (HasMultipleSelection())
    {
        lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
                                        ,LM_QUERYSELECTION
                                        ,(MPARAM)LIT_FIRST
                                        ,(MPARAM)0
                                       )
                          );
        if (lItem != LIT_NONE)
        {
            nCount++;
            while ((lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
                                                    ,LM_QUERYSELECTION
                                                    ,(MPARAM)lItem
                                                    ,(MPARAM)0
                                                   )
                                      )) != LIT_NONE)
            {
                nCount++;
            }
            raSelections.Alloc(nCount);
            lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
                                            ,LM_QUERYSELECTION
                                            ,(MPARAM)LIT_FIRST
                                            ,(MPARAM)0
                                           )
                              );

            raSelections.Add((int)lItem);
            while ((lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
                                                    ,LM_QUERYSELECTION
                                                    ,(MPARAM)lItem
                                                    ,(MPARAM)0
                                                   )
                                      )) != LIT_NONE)
            {
                raSelections.Add((int)lItem);
            }
            return nCount;
        }
    }
    else  // single-selection listbox
    {
        lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
                                        ,LM_QUERYSELECTION
                                        ,(MPARAM)LIT_FIRST
                                        ,(MPARAM)0
                                       )
                          );
        raSelections.Add((int)lItem);
        return 1;
    }
    return 0;
} // end of wxListBox::GetSelections
Exemplo n.º 19
0
Arquivo: kimehook.c Projeto: komh/kime
BOOL ztelnetAccelHook( PQMSG pQmsg )
{
    if( pQmsg->msg == WM_CHAR )
    {
        USHORT  fsFlags = SHORT1FROMMP( pQmsg->mp1 );
        //UCHAR   ucRepeat = CHAR3FROMMP( pQmsg->mp1 );
        //UCHAR   ucScancode = CHAR4FROMMP( pQmsg->mp1 );
        USHORT  usCh = SHORT1FROMMP( pQmsg->mp2 );
        USHORT  usVk = SHORT2FROMMP( pQmsg->mp2 );

        if( fsFlags & KC_KEYUP )
            return FALSE;

        if(( fsFlags & ( KC_SHIFT | KC_CTRL )) && ( usVk == VK_SPACE ))
        {
            WinSendMsg( hwndKime, KIMEM_CHANGEHAN, 0, 0 );
            WinSendMsg( hwndKHS, KHSM_CHANGEHANSTATUS, MPFROMHWND( pQmsg->hwnd ), 0 );
        }
        else if( !( fsFlags & KC_ALT ) && ( usVk == VK_F3 ))
        {
            WinSendMsg( hwndKime, KIMEM_CHANGEIM, 0, 0 );
            WinSendMsg( hwndKHS, KHSM_CHANGEIMSTATUS, MPFROMHWND( pQmsg->hwnd ), 0 );
        }
        else if( LONGFROMMR( WinSendMsg( hwndKime, KIMEM_QUERYHAN, 0, 0 ))
                 && ( !( fsFlags & ( KC_CTRL | KC_ALT ))))
        {
            UCHAR uch;
            UCHAR *kbdConv;
            BOOL  shiftOn;

            usCh = kbdKeyTranslate( pQmsg );
            uch = tolower( LOUCHAR( usCh ));
            if( fsFlags & KC_SHIFT )
                uch = toupper( uch );
            else if( kimeOpt.patchChat && prevHanInput &&
                     LONGFROMMR( WinSendMsg( hwndKime, KIMEM_QUERYIM, 0, 0 )) &&
                     ( usVk == VK_SPACE ))
                     WinSendMsg( pQmsg->hwnd, pQmsg->msg, pQmsg->mp1, pQmsg->mp2 );

            shiftOn = FALSE;
            if( isDblJaum( uch ))
            {
                if( dblJaumPressed )
                {
                    if( uchPrevDbl == uch )
                    {
                        if( kimeOpt.patch3bul )
                            WinSendMsg( pQmsg->hwnd, WM_CHAR,
                                        MPFROMSH2CH( fsFlags | KC_VIRTUALKEY, 0, 0 ),
                                        MPFROM2SHORT( 0, VK_BACKSPACE ));

                        uchPrevDbl = 0;
                        dblJaumPressed = FALSE;
                        shiftOn = TRUE;
                    }
                    else
                        uchPrevDbl = uch;
                }
                else
                {
                    uchPrevDbl = uch;
                    dblJaumPressed = TRUE;
                }
            }
            else
                dblJaumPressed = FALSE;

            if(( kbdConv = findKbdConv( uch )) != NULL )
            {
                fsFlags &= ~KC_SHIFT;
                if( kbdConv[ 3 ] || shiftOn )
                    fsFlags |= KC_SHIFT;

                usCh = MAKEUSHORT( kbdConv[ 1 ], 0 );
                if( kbdConv[ 2 ])
                {
                    if( kimeOpt.patch3bul )
                        WinSendMsg( pQmsg->hwnd, WM_CHAR,
                                    MPFROMSH2CH( fsFlags, 0, 0 ),
                                    MPFROM2SHORT( usCh, 0 ));

                    usCh = MAKEUSHORT( kbdConv[ 2 ], 0 );
                }

                if( usCh )
                {
                    if( kimeOpt.patch3bul )
                    {
                        //pQmsg->mp1 = MPFROMSH2CH( fsFlags, ucRepeat, ucScancode );
                        //pQmsg->mp2 = MPFROM2SHORT( usCh, usVk );

                        pQmsg->mp1 = MPFROMSH2CH( fsFlags, 0, 0 );
                        pQmsg->mp2 = MPFROM2SHORT( usCh, 0 );
                    }
                }
            }

            prevHanInput = ( strchr( SBCS_CHARS, SHORT1FROMMP( pQmsg->mp2 )) == NULL ) &&
                           !( fsFlags & KC_VIRTUALKEY );
        }
    }

    return FALSE;
}
Exemplo n.º 20
0
bool wxTextEntry::IsEditable() const
{
    return (bool)LONGFROMMR(::WinSendMsg(GetEditHwnd(), EM_QUERYREADONLY, 0, 0));
}
Exemplo n.º 21
0
bool wxCheckBox::GetValue() const
{
    return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK, (MPARAM)0, (MPARAM)0)) == 1L));
} // end of wxCheckBox::GetValue
Exemplo n.º 22
0
unsigned int wxChoice::GetCount() const
{
    return((unsigned int)LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMCOUNT, (MPARAM)0, (MPARAM)0)));
} // end of wxChoice::GetCount
Exemplo n.º 23
0
//
// Same as AddPage() but does it at given position
//
bool wxNotebook::InsertPage ( size_t          nPage,
                              wxNotebookPage* pPage,
                              const wxString& rsStrText,
                              bool            bSelect,
                              int             nImageId )
{
    ULONG                           ulApiPage;

    wxASSERT( pPage != NULL );
    wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false );

    //
    // Under OS/2 we can only insert FIRST, LAST, NEXT or PREV.  Requires
    // two different calls to the API.  Page 1 uses the BKA_FIRST.  Subsequent
    // pages use the previous page ID coupled with a BKA_NEXT call.  Unlike
    // Windows, OS/2 uses an internal Page ID to ID the pages.
    //
    // OS/2 also has a nice auto-size feature that automatically sizes the
    // the attached window so we don't have to worry about the size of the
    // window on the page.
    //
    if (nPage == 0)
    {
        ulApiPage = LONGFROMMR(::WinSendMsg( GetHWND()
                                            ,BKM_INSERTPAGE
                                            ,(MPARAM)0
                                            ,MPFROM2SHORT(BKA_AUTOPAGESIZE | BKA_MAJOR, BKA_FIRST)
                                           ));
        if (ulApiPage == 0L)
        {
            ERRORID                 vError;
            wxString                sError;

            vError = ::WinGetLastError(vHabmain);
            sError = wxPMErrorToStr(vError);
            return false;
        }
        m_alPageId.Insert((long)ulApiPage, nPage);
    }
    else
    {
        ulApiPage = LONGFROMMR(::WinSendMsg( GetHWND()
                                            ,BKM_INSERTPAGE
                                            ,MPFROMLONG((ULONG)m_alPageId[nPage - 1])
                                            ,MPFROM2SHORT(BKA_AUTOPAGESIZE | BKA_MAJOR, BKA_NEXT)
                                           ));
        if (ulApiPage == 0L)
        {
            ERRORID                     vError;
            wxString                    sError;

            vError = ::WinGetLastError(vHabmain);
            sError = wxPMErrorToStr(vError);
            return false;
        }
        m_alPageId.Insert((long)ulApiPage, nPage);
    }

    //
    // Associate a window handle with the page
    //
    if (pPage)
    {
        if (!::WinSendMsg( GetHWND()
                          ,BKM_SETPAGEWINDOWHWND
                          ,MPFROMLONG((ULONG)m_alPageId[nPage])
                          ,MPFROMHWND(pPage->GetHWND())
                         ))
            return false;
    }
    //
    // If the inserted page is before the selected one, we must update the
    // index of the selected page
    //
    if (nPage <= (size_t)m_nSelection)
    {
        //
        // One extra page added
        //
        m_nSelection++;
    }

    if (pPage)
    {
        //
        // Save the pointer to the page
        //
        m_pages.Insert( pPage
                       ,nPage
                      );
    }

    //
    // Now set TAB dimenstions
    //

    wxWindowDC vDC(this);
    wxCoord    nTextX;
    wxCoord    nTextY;

    vDC.GetTextExtent(rsStrText, &nTextX, &nTextY);
    nTextY *= 2;
    nTextX  = (wxCoord)(nTextX * 1.3);
    if (nTextX > m_nTabSize)
    {
        m_nTabSize = nTextX;
        ::WinSendMsg( GetHWND()
                     ,BKM_SETDIMENSIONS
                     ,MPFROM2SHORT((USHORT)m_nTabSize, (USHORT)nTextY)
                     ,(MPARAM)BKA_MAJORTAB
                    );
    }
    //
    // Now set any TAB text
    //
    if (!rsStrText.empty())
    {
        if (!SetPageText( nPage
                         ,rsStrText
                        ))
            return false;
    }

    //
    // Now set any TAB bitmap image
    //
    if (nImageId != -1)
    {
        if (!SetPageImage( nPage
                          ,nImageId
                         ))
            return false;
    }

    if (pPage)
    {
        //
        // Don't show pages by default (we'll need to adjust their size first)
        //
        HWND hWnd = GetWinHwnd(pPage);

        WinSetWindowULong( hWnd
                          ,QWL_STYLE
                          ,WinQueryWindowULong( hWnd
                                               ,QWL_STYLE
                                              ) & ~WS_VISIBLE
                         );

        //
        // This updates internal flag too - otherwise it will get out of sync
        //
        pPage->Show(false);
    }

    //
    // Some page should be selected: either this one or the first one if there is
    // still no selection
    //
    int nSelNew = -1;

    if (bSelect)
        nSelNew = nPage;
    else if ( m_nSelection == -1 )
        nSelNew = 0;

    if (nSelNew != -1)
        SetSelection(nSelNew);

    InvalidateBestSize();

    return true;
} // end of wxNotebook::InsertPage
Exemplo n.º 24
0
Arquivo: kimehook.c Projeto: komh/kime
MRESULT EXPENTRY newKimeWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
    if( msg == KIMEM_RELOAD )
    {
        WinSendMsg( hwndKHS, KHSM_RELOADEXCEPTFILE, 0, 0 );
        hwndCurrentInput = NULLHANDLE;
    }

    if( msg == KIMEM_CALLHANJAINPUT )
    {
        initKimeStatus( hwndCurrentInput, FALSE );

        WinSendMsg( hwndHIA, WM_CHAR, MPFROMSH2CH( KC_LONEKEY | KC_SCANCODE, 0, 0x5B ), 0 );

        WinSetFocus( HWND_DESKTOP, hwndCurrentInput );

        return 0;
    }

    if( msg == KIMEM_CHANGEHANHOOK )
    {
        WinSendMsg( hwndHIA, HIAM_CHANGEHANMODE, 0, 0 );

        if( kimeOpt.useOS2IME )
            toggleOS2IMEHanEng( hwndCurrentInput );

        return 0;
    }

    if( msg == WM_CONTROL )
    {
        switch (SHORT1FROMMP(mp1))
        {
            case ID_HIA:
                switch (SHORT2FROMMP(mp1))
                {
                    case HIAN_INSERTHCH:
                        if (!(SHORT1FROMMP(mp2) & 0x8000))
                        {
                            sendCharToWnd( SHORT1FROMMP( mp2 ));

                            setInputBoxHch( 0 );
                            showInputBox( FALSE );
                        }
                        break;

                    case HIAN_COMPO_BEGIN:
                    case HIAN_COMPO_STEP:
                    case HIAN_COMPO_STEPBACK:
                        hchComposing = SHORT2FROMMP(mp2);

                        setInputBoxHch( hchComposing );
                        showInputBox( TRUE );
                        break;

#if 0
                    case HIAN_COMPO_STEP:
                        hchComposing = SHORT2FROMMP(mp2);

                        setInputBoxHch( hchComposing );
                        break;

                    case HIAN_COMPO_STEPBACK:
                        hchComposing = SHORT2FROMMP(mp2);

                        setInputBoxHch( hchComposing );
                        break;
#endif

                    case HIAN_COMPO_CANCEL:
                        setInputBoxHch( 0 );
                        showInputBox( FALSE );
                        hchComposing = 0;
                        break;

                    case HIAN_COMPO_COMPLETE:
                        sendCharToWnd( SHORT1FROMMP( mp2 ));

                        setInputBoxHch( 0 );
                        showInputBox( FALSE );
                        hchComposing = 0;
                        break;

                    case HIAN_HANMODECHANGED:
                        WinSendMsg( hwndKHS, KHSM_SETHANSTATUS, MPFROMHWND( hwndCurrentInput ), MPFROMLONG( LONGFROMMP( mp2 ) == HCH_HAN ));
                        WinSendMsg( hwndKime, KIMEM_SETHAN, MPFROMLONG( LONGFROMMP( mp2 ) == HCH_HAN ), 0 );
                        break;

                    case HIAN_KBDTYPECHANGED:
                        kimeOpt.kbdLayout = LONGFROMMR( mp2 );
                        break;

                    case HIAN_INSERTMODECHANGED:
                        break;

                    case HIAN_HGHJCONVERT:
                        WinSendMsg( hwndHIA, WM_CHAR, 0, 0 ); // call special char input

                        WinSetFocus( HWND_DESKTOP, hwndCurrentInput);
                        break;

                } // note switch end
                break;
        } // control switch end

        return 0;
    }

    return oldKimeWndProc( hwnd, msg, mp1, mp2 );
}
Exemplo n.º 25
0
void
FillMenu( HWND hwndMenu )
{
  char      szPidPath[1024];
  char      szBuffer[1024];
  char*     pBuf;
  QSPTRREC* pRecHead;
  QSPREC*   pApp;
  int       numItems, iCounter;
  PVOID     pBuffer;
  PSWBLOCK  pSB;
  TASKDATA* data;
  SHORT     id = ID_ITEM_FIRST;

  // Delete all current items
  numItems = LONGFROMMR( WinSendMsg( hwndMenu, MM_QUERYITEMCOUNT, 0, 0 ));

  while( numItems-- )
  {
    MENUITEM mi;
    SHORT    id = LONGFROMMR( WinSendMsg( hwndMenu,
                              MM_ITEMIDFROMPOSITION, MPFROMSHORT(0), 0 ));

    if( WinSendMsg( hwndMenu, MM_QUERYITEM,
                    MPFROM2SHORT( id, FALSE ), MPFROMP( &mi )))
    {
      if( mi.hItem )
      {
        data = (TASKDATA*)mi.hItem;

        free( data->szTitle );
        free( data );
      }
    }

    WinSendMsg( hwndMenu, MM_DELETEITEM,
                MPFROM2SHORT( id, FALSE ), 0 );
  }

  if( bType )
  {
    // Ctrl is pressed, get the processes in the system.
    pBuf = (char*)malloc( 0x8000 );

    // Get processes
    DosQuerySysState( QS_PROCESS, 0, 0, 0, (char*)pBuf, 0x8000 );

    // Point to first process
    pRecHead = (QSPTRREC*)pBuf;
    pApp = pRecHead->pProcRec;

    // While its a process record
    while( pApp->RecType == 1 )
    {
      // Get module name for process
      memset( szPidPath, 0, _MAX_PATH );
      DosQueryModuleName( pApp->hMte, 512, szPidPath );

      if( strlen( szPidPath ) == 0 )
      {
        // If no hit is the kernel
        if( pApp->type == 1 ) {
          sprintf( szPidPath, "VDM (%d)", pApp->pid );
        } else {
          strcpy ( szPidPath, "*SYSINIT" );
        }
      }
      else
      {
        // Else trim the path
        strcpy ( szBuffer, FileGetFileExt( szPidPath ));
        sprintf( szPidPath, "%s (%d)", szBuffer, pApp->pid );
      }

      // add to menu
      data = (TASKDATA*)malloc( sizeof( TASKDATA ));
      data->szTitle = strdup( szPidPath );
      data->hWindow = NULLHANDLE;
      data->pid = pApp->pid;

      switch( pApp->type ) {
        case  0: data->hIcon = ico_os2fs;  break;
        case  1: data->hIcon = ico_dos;    break;
        case  2: data->hIcon = ico_os2vio; break;
        case  3: data->hIcon = ico_pm;     break;
        case  4: data->hIcon = ico_detach; break;
        default: data->hIcon = NULLHANDLE; break;
      }

      winhInsertMenuItem( hwndMenu, MIT_END,
                          id++, szPidPath, MIS_OWNERDRAW, 0, data );
      // get next record
      pApp=(QSPREC *)((pApp->pThrdRec) + pApp->cTCB);
    }

    free(pBuf);
  }
  else
  {
    // Get number of items in switchlist
    numItems = WinQuerySwitchList( WinQueryAnchorBlock( hwndMenu ), NULL, 0 );

    // Get all items into buffer
    pBuffer = malloc(( numItems * sizeof(SWENTRY)) + sizeof(HSWITCH));

    WinQuerySwitchList( WinQueryAnchorBlock(hwndMenu),
                        (SWBLOCK*)pBuffer,
                        (numItems * sizeof(SWENTRY)) + sizeof(HSWITCH));

    pSB = (PSWBLOCK)(pBuffer);
    for( iCounter = 0; iCounter < numItems; iCounter++ )
    {
      // Should be JUMPABLE and VISIBLE to show in list
      if( pSB->aswentry[iCounter].swctl.uchVisibility == SWL_VISIBLE )
      {

        // Put in menu
        data = (TASKDATA*)malloc( sizeof( TASKDATA ));
        data->szTitle = strdup( pSB->aswentry[iCounter].swctl.szSwtitle );
        data->hWindow = pSB->aswentry[iCounter].swctl.hwnd;
        data->pid = pSB->aswentry[iCounter].swctl.idProcess;
        CleanString( data->szTitle );

        if( pSB->aswentry[iCounter].swctl.hwndIcon != NULLHANDLE ) {
          data->hIcon = pSB->aswentry[iCounter].swctl.hwndIcon;
        } else {
          data->hIcon = (HPOINTER)WinSendMsg( data->hWindow, WM_QUERYICON, 0, 0 );
        }

        winhInsertMenuItem( hwndMenu, MIT_END, id++,
                            pSB->aswentry[iCounter].swctl.szSwtitle,
                            MIS_OWNERDRAW, 0, data );
      }
    }
    free(pBuffer);
  }
}
Exemplo n.º 26
0
int ImportFileProc (void)

{
static FILEDLG fild;                   //File dialog box structure
HWND hwndfild;                 //Handle of file dialog box
HFILE hfile;
ULONG ulAction;
APIRET apiRes;
PCHAR pchar;
IPT lOffset=0;
ULONG cbBytesRead;
PVOID pvBuf;             //pointer to buffer to hold file.
long BUFSIZE=60000;
ULONG cbBytesImported;



////Prepare open common dialog structure.

//Set all fields to 0
memset(&fild,0,sizeof(FILEDLG));

//Set size of structure
fild.cbSize=sizeof(FILEDLG);

//Set dialog type
fild.fl=FDS_CENTER|FDS_OPEN_DIALOG;

//Set title
fild.pszTitle="Import File";

SHOWDIALOG:             //Used by goto when a file is invalid.

//Set initial path and filename
strcpy(fild.szFullFile,szCurrentDirectory);
if(szCurrentDirectory[0]!='*')
  strcat(fild.szFullFile,"*.*");

//Show open common dialog, if a file was not passed in
hwndfild=WinFileDlg(HWND_DESKTOP,hwndClient, &fild);

//If OK was pressed on dialog, open selected file.
if (fild.lReturn==DID_OK)
    {
        //Convert to upper case if not in case sensitive mode
        if(!gbCaseSensitiveFileNames) strupr(fild.szFullFile);

        //Try to open the file to make sure it is valid.
         apiRes=DosOpen(fild.szFullFile,
               &hfile,   
               &ulAction,
               0,
               FILE_NORMAL,
               FILE_OPEN,
               OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE,
               NULL);

        //Close the file
        DosClose(hfile);
        if (apiRes)
           {
           //Handle bad return code from DosOpen.
           switch(apiRes)
                {
                   case ERROR_FILE_NOT_FOUND:
                   case ERROR_PATH_NOT_FOUND:
                            WinMessageBox(HWND_DESKTOP, hwndClient, "File not found.",
                                "Open File", 0,
                                MB_OK|
                                MB_MOVEABLE|
                                MB_ICONEXCLAMATION|MB_SYSTEMMODAL);
                            break;
                   case ERROR_ACCESS_DENIED:
                            WinMessageBox(HWND_DESKTOP, hwndClient, "Access denied.",
                                "Open File", 0,
                                MB_OK|
                                MB_MOVEABLE|
                                MB_ICONEXCLAMATION|MB_SYSTEMMODAL);
                            break;
                   case ERROR_SHARING_VIOLATION:
                           WinMessageBox(HWND_DESKTOP, hwndClient, "Sharing violation.",
                                "Open File", 0,
                                MB_OK|
                                MB_MOVEABLE|
                                MB_ICONEXCLAMATION|MB_SYSTEMMODAL);
                           break;
                   default: 
                           WinMessageBox(HWND_DESKTOP, hwndClient, "Can't access file",
                                "Open File", 0,
                                MB_OK|
                                MB_MOVEABLE|
                                MB_ICONEXCLAMATION|MB_SYSTEMMODAL);


                }
           //Redisplay file open dialog
           goto SHOWDIALOG;
           }
    }
else
    {
    //User pressed cancel
    return 0;
    }
    

/////////////////////////////////////////////////////////
//Save the current directory.
//This is so the next time the dialog is brought up
//it is in the expected directory.
//Get the file name from the dialog box structure
strcpy(szCurrentDirectory, fild.szFullFile);
//Set a pointer to end of filename.
pchar=szCurrentDirectory+sizeof(szCurrentDirectory);
//Back up until we hit a "\"
while((*pchar!='\\') && (pchar!=szCurrentDirectory)) pchar--;
//Move forward one and set a null
if(*pchar=='\\')
        {
        pchar++;
        *pchar='\0';
        }
else
        {
        //Else this is not a path, so delete it
        strcpy(szCurrentDirectory,"");
        }
////////////////////////////////////////////////////



//Disable file menu
EnableFileMenu(FALSE);

//Open the file
if (DosOpen(fild.szFullFile, &hfile, &ulAction,0,FILE_NORMAL,
                        FILE_OPEN,
                        OPEN_ACCESS_READONLY|OPEN_SHARE_DENYNONE,
                        NULL))
                {
                //Show error message
                ErrorMessage("Could not open file.");
                goto ENDIMPORT;
                }

//Allocate a buffer.
if (DosAllocMem((PPVOID)&pvBuf, BUFSIZE, fALLOC))
{
        //Close the file
        DosClose(hfile);

        //Error allocating memory.
        ErrorMessage("Could not allocate memory to import file.");

        goto ENDIMPORT;
}

//Set MLE import buffer.
WinSendMsg(hwndMLE, 
        MLM_SETIMPORTEXPORT,
        MPFROMP((PBYTE)pvBuf),
        MPFROMLONG(BUFSIZE));

//Disable MLE auto-refresh and hide it.
WinSendMsg(hwndMLE,
        MLM_DISABLEREFRESH,
        MPVOID,
        MPVOID);

//Get offset into MLE
lOffset=LONGFROMMR(WinSendMsg(hwndMLE,
                                        MLM_QUERYSEL,
                                        MPFROMSHORT(MLFQS_CURSORSEL),
                                        MPVOID));

//Read the file and import into MLE window
do
  {
        //Sleep a bit
        DosSleep(100);

        //Read in some of the file
        if (DosRead(hfile, pvBuf, BUFSIZE, &cbBytesRead))
        {
        //Show error message
        ErrorMessage("File read failed.");

        //An error occured
        goto ENDIMPORT;
        }


        //Import text to MLE if there were bytes read in.
        if(cbBytesRead>0)
        {
                cbBytesImported=LONGFROMMR(WinSendMsg(hwndMLE, 
                                                MLM_IMPORT,
                                                MPFROMP(&lOffset),
                                                MPFROMLONG(cbBytesRead)));

                if(!cbBytesImported)
                {
                        //Show error message
                        ErrorMessage("Text not imported.");

                        //Bytes were not imported, error
                        goto ENDIMPORT;

                }
        }


 
} while (cbBytesRead>0); //End do




//Label for end of function, errors goto here.
ENDIMPORT:

//Reset current line and column
ResetLineColumnStatus();

UpdateKeyStatus();

WinSendMsg(hwndMLE, MLM_ENABLEREFRESH, MPVOID, MPVOID);

//Close the file
DosClose(hfile);

//Free the memory
DosFreeMem(pvBuf);

//Enable file menu
EnableFileMenu(TRUE);

return 0;
}