MRESULT EXPENTRY NewFrameProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 ) { PFNWP oldFrameProc ; /* ------- get original frame procedure --------- */ oldFrameProc = (PFNWP) WinQueryWindowULong( hwnd, QWL_USER ); switch (msg) { case WM_QUERYFRAMECTLCOUNT : { USHORT itemCount ; /* ---- get count of original frame controls --- */ itemCount = SHORT1FROMMR( oldFrameProc( hwnd, msg, mp1, mp2 )); /* ------- add 1 for new toolbar control ------ */ return ( (MRESULT) ++itemCount ); } case WM_FORMATFRAME : { PSWP pSWP ; PRECTL pFrameRect ; USHORT itemCount ; pFrameRect = PVOIDFROMMP( mp2 ); pSWP = PVOIDFROMMP( mp1 ); /* ---- run regular processing on original controls --- */ itemCount = SHORT1FROMMR( oldFrameProc( hwnd, msg, mp1, mp2 )); /* ---- get size values for 2nd menu bar -------- */ pSWP[ itemCount ].fl = SWP_SIZE; pSWP[ itemCount ].cy = pSWP[(itemCount-1)].cy ; /* set some */ pSWP[ itemCount ].cx = pSWP[(itemCount-1)].cx ; /* defaults */ pSWP[ itemCount ].hwndInsertBehind = HWND_TOP ; pSWP[ itemCount ].hwnd = hwndMenuBar ; WinSendMsg( hwndMenuBar, /* let the menu code make */ WM_ADJUSTWINDOWPOS, /* the actual size */ MPFROMP( pSWP+itemCount ), /* adjustments */ (MPARAM) 0L ); /* ------ position menu directly below other menu ------- */ pSWP[itemCount].x = pSWP[(itemCount-2)].x ; pSWP[itemCount].y = pSWP[(itemCount-2)].y - pSWP[itemCount].cy ; pSWP[itemCount].fl = pSWP[(itemCount-2)].fl ; /* -------- adjust client window size for 2nd menu ------- */ pSWP[(itemCount-1)].cy -= pSWP[itemCount].cy ; /* -------- return total count of frame controls ------- */ return( MRFROMSHORT( ++itemCount ) ); } break; default: return oldFrameProc(hwnd,msg,mp1,mp2); } /* end of switch () */ return( FALSE ); } /* end of NewFrameProc */
void InitSortMenu( HWND hwnd) { SHORT pos; ULONG ctr; HWND hMenu; MENUITEM mi; SetSortIndicatorMenu( hwnd, 0); // get the Sort submenu hMenu = WinWindowFromID( hwnd, FID_MENU); WinSendMsg( hMenu, MM_QUERYITEM, MPFROM2SHORT( IDM_SORT, 0), &mi); hMenu = mi.hwndSubMenu; pos = SHORT1FROMMR( WinSendMsg( hMenu, MM_ITEMPOSITIONFROMID, MPFROM2SHORT( IDM_SORTFIRST, 0), 0)); if (pos < 0) pos = 2; for (ctr = 0; ctr < eCNTCOLS; ctr++) if (SHORT1FROMMR( WinSendMsg( hMenu, MM_DELETEITEM, MPFROM2SHORT( IDM_SORTFIRST + ctr, 0), 0) <= 0)) { printf( "InitSortMenu - early exit, ctr= %d\n", (int)ctr); break; } mi.afStyle = MIS_TEXT; mi.hwndSubMenu = 0; mi.hItem = 0; // insert a menuitem for each column for (ctr = 0; ctr < eCNTCOLS; ctr++, pos++) { mi.iPosition = pos; if (ciX[ctr]->flags & CIF_INVISIBLE) mi.afAttribute = MIA_DISABLED | MIA_NODISMISS; else mi.afAttribute = MIA_NODISMISS; mi.id = (USHORT)(IDM_SORTFIRST + (ciX[ctr]->flags & CIF_NDXMASK)); WinSendMsg( hMenu, MM_INSERTITEM, (MP)&mi, (MP)ciX[ctr]->pszMenu); } // update the sort info without changing the sort column or direction SetSortColumn( hwnd, (ULONG)-1); return; }
MRESULT ChannelSwap(MPARAM mp1, MPARAM mp2) { VolChannelSwap = (BOOL)SHORT1FROMMR(WinSendMsg(hwndChannelSwap, BM_QUERYCHECK, NULL, NULL)); return NULL; }
MRESULT ChannelIndependent(MPARAM mp1, MPARAM mp2) { VolChannelIndependent = (BOOL)SHORT1FROMMR(WinSendMsg(hwndChannelIndependent, BM_QUERYCHECK, NULL, NULL)); return NULL; }
extern VOID AddSysMenuItem ( HWND hwndFrame, MENUITEM *Item, PSZ Text ) { /*************************************************************************** * Local Declarations * ***************************************************************************/ HWND hwndSysMenu ; HWND hwndSysSubMenu ; USHORT idSysMenu ; MENUITEM miSysMenu ; /*************************************************************************** * Obtain the system menu window handle. * ***************************************************************************/ hwndSysMenu = WinWindowFromID ( hwndFrame, FID_SYSMENU ) ; /*************************************************************************** * Get the system menu's base item and its window handle. * ***************************************************************************/ idSysMenu = SHORT1FROMMR ( WinSendMsg ( hwndSysMenu, MM_ITEMIDFROMPOSITION, NULL, NULL ) ) ; WinSendMsg ( hwndSysMenu, MM_QUERYITEM, MPFROM2SHORT(idSysMenu,FALSE), MPFROMP(&miSysMenu) ) ; hwndSysSubMenu = miSysMenu.hwndSubMenu ; /*************************************************************************** * Add the new item to the system menu's submenu, which is what we see. * ***************************************************************************/ WinSendMsg ( hwndSysSubMenu, MM_INSERTITEM, MPFROMP(Item), MPFROMP(Text) ) ; }
static void AddCancelItem(HWND hwnd) { HWND hSysMenu, hSysSubMenu; MENUITEM SysMenu; SHORT idSysMenu; MENUITEM Item[2] = {{MIT_END, MIS_SEPARATOR, 0, 0, NULLHANDLE, 0}, {MIT_END, MIS_TEXT, 0, IDM_AS_CANCEL, NULLHANDLE, 0}}; char pchTemp[100]=""; hSysMenu = WinWindowFromID(hwnd, FID_SYSMENU); idSysMenu = SHORT1FROMMR(SendMsg(hSysMenu, MM_ITEMIDFROMPOSITION, NULL, NULL)); SendMsg(hSysMenu, MM_QUERYITEM, MPFROM2SHORT(idSysMenu, FALSE), &SysMenu); hSysSubMenu = SysMenu.hwndSubMenu; LoadString(IDST_AP_CANCEL, sizeof(pchTemp), pchTemp); SendMsg(hSysSubMenu, MM_INSERTITEM, &Item[0], NULL); SendMsg(hSysSubMenu, MM_INSERTITEM, &Item[1], pchTemp); return; }
/* * * SetSysMenu * * DESCRIPTION: * * Set dialog box so only move and close are active. * */ static VOID SetSysMenu( HWND hDlg) { HWND hSysMenu; MENUITEM Mi; ULONG Pos; MRESULT Id; SHORT cItems; /******************************************************************/ /* We only want Move and Close in the system menu. */ /******************************************************************/ hSysMenu = WinWindowFromID(hDlg, FID_SYSMENU); WinSendMsg( hSysMenu, MM_QUERYITEM , MPFROM2SHORT(SC_SYSMENU, FALSE), MPFROMP((PCH) & Mi)); Pos = 0L; cItems = (SHORT)WinSendMsg( Mi.hwndSubMenu, MM_QUERYITEMCOUNT, (MPARAM)NULL, (MPARAM)NULL); while( cItems--){ Id = WinSendMsg( Mi.hwndSubMenu, MM_ITEMIDFROMPOSITION , MPFROMLONG(Pos), (MPARAM)NULL); switch (SHORT1FROMMR(Id)) { case SC_MOVE: case SC_CLOSE: Pos++; /* Don't delete that one. */ break; default: WinSendMsg( Mi.hwndSubMenu, MM_DELETEITEM , MPFROM2SHORT((USHORT)Id, TRUE), (MPARAM)NULL); } } }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static CHAR *szMenuText [3] = { NULL, "A~bout PoorMenu...", "~Help..." } ; static MENUITEM mi [3] = { MIT_END, MIS_SEPARATOR, 0, 0, 0, 0, MIT_END, MIS_TEXT, 0, IDM_ABOUT, 0, 0, MIT_END, MIS_TEXT, 0, IDM_HELP, 0, 0 } ; HWND hwndSysMenu, hwndSysSubMenu ; INT iItem, idSysMenu ; MENUITEM miSysMenu ; switch (msg) { case WM_CREATE: hwndSysMenu = WinWindowFromID ( WinQueryWindow (hwnd, QW_PARENT), FID_SYSMENU) ; idSysMenu = SHORT1FROMMR (WinSendMsg (hwndSysMenu, MM_ITEMIDFROMPOSITION, NULL, NULL)) ; WinSendMsg (hwndSysMenu, MM_QUERYITEM, MPFROM2SHORT (idSysMenu, FALSE), MPFROMP (&miSysMenu)) ; hwndSysSubMenu = miSysMenu.hwndSubMenu ; for (iItem = 0 ; iItem < 3 ; iItem++) WinSendMsg (hwndSysSubMenu, MM_INSERTITEM, MPFROMP (mi + iItem), MPFROMP (szMenuText [iItem])) ; return 0 ; case WM_COMMAND: switch (COMMANDMSG(&msg)->cmd) { case IDM_ABOUT: WinMessageBox (HWND_DESKTOP, hwnd, "(C) Charles Petzold, 1993", szCaption, 0, MB_OK | MB_INFORMATION) ; return 0 ; case IDM_HELP: WinMessageBox (HWND_DESKTOP, hwnd, "Help not yet implemented", szCaption, 0, MB_OK | MB_WARNING) ; return 0 ; } break ; case WM_ERASEBACKGROUND: return MRFROMSHORT (1) ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
// // Get item state // -------------- bool wxMenuItem::IsChecked() const { USHORT uFlag = SHORT1FROMMR(::WinSendMsg( GetHMenuOf(m_parentMenu) ,MM_QUERYITEMATTR ,MPFROM2SHORT(GetId(), TRUE) ,MPFROMSHORT(MIA_CHECKED) )); return (uFlag & MIA_CHECKED) == MIA_CHECKED ; } // end of wxMenuItem::IsChecked
void DrvEjectAllDrives( HWND hwnd) { HWND hList; SHORT ndx; char chDrive; hList = WinWindowFromID( hwnd, IDC_CAMLIST); while ((ndx = SHORT1FROMMR( WinSendMsg( hList, LM_QUERYSELECTION, (MP)LIT_FIRST, 0))) != LIT_NONE) { chDrive = (char)SHORT1FROMMR( WinSendMsg( hList, LM_QUERYITEMHANDLE, MPFROM2SHORT( ndx, 0), 0)); if (!DrvEjectDrive( chDrive)) WinSendMsg( hList, LM_DELETEITEM, MPFROM2SHORT( ndx, 0), 0); else WinSendMsg( hList, LM_SELECTITEM, MPFROM2SHORT( ndx, 0), (MP)FALSE); } return; }
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; }
/*����������������������������������������������������������������������������*/ static VOID LoadMpFormats(HWND hwndDlg, USHORT usDropDownList, MP_FORMAT defMP) { USHORT usThisItem; /* where this MP added to list */ MP_FORMAT mpThis; /* current MP Format */ /************************************************************************** * Determine HWND of drop-down list once **************************************************************************/ HWND hwndDD = WinWindowFromID(hwndDlg, usDropDownList); /************************************************************************** * Add all MP format items to the specified drop-down list **************************************************************************/ for( mpThis = MP_First; /* Initialize: start @ first */ mpThis < MP_Total; /* While: still more MP formats */ mpThis++ /* Iterate: try the next */ ) { /************************************************************************ * Add this MP format item remembering "where" it went ************************************************************************/ usThisItem = SHORT1FROMMR(WinSendMsg(hwndDD, LM_INSERTITEM, MPFROMSHORT(LIT_END), MPFROMP(MpDisplayText(mpThis))) ); /************************************************************************ * Set item's "handle" to MP format value ************************************************************************/ WinSendMsg(hwndDD, /* Window Handle */ LM_SETITEMHANDLE, /* Message */ MPFROMSHORT(usThisItem), /* Index of list item */ MPFROMSHORT(mpThis) ); /* "Handle" of list item */ /************************************************************************ * If this is the designated "default" MP format items, select it ************************************************************************/ if (mpThis == defMP) WinSendMsg(hwndDD, LM_SELECTITEM, /* Select item */ MPFROMSHORT(usThisItem), /* Item = This */ MPFROMSHORT(TRUE)); /* Select = Yes */ } }
MRESULT khs_umCheckDBCSSupport( HWND hwnd, MPARAM mp1, MPARAM mp2 ) { PKHSCD pkhscd = WinQueryWindowPtr( hwnd, 0 ); HWND hwndTarget = HWNDFROMMP( mp1 ); PID pid; USHORT qcp; WinQueryWindowProcess( hwndTarget, &pid, NULL ); DosGiveSharedMem( pkhscd->pCursorPos, pid, PAG_READ | PAG_WRITE ); qcp = SHORT1FROMMR( WinSendMsg( hwndTarget, WM_QUERYCONVERTPOS, MPFROMP( pkhscd->pCursorPos ), 0 )); return MRFROMLONG( qcp == QCP_CONVERT ); }
/*@ XToolBar::SetHeight(const USHORT y) @group sizing @remarks Set the hight of the toolbar @parameters USHORT ySize the new hight in pixels */ BOOL XToolBar::SetHeight(const USHORT y) { SWP swp[200]; if (IsVisible()) cy = y; /* if (line1) { line1->SetHeight(y - 2); XPoint p(0, y - 2); line2->Move(&p); p.Set(cx - 1, 0); line3->Move(&p); line3->SetHeight(y - 2); } */ if (frame && frame->frameWin) { SWP swp2; WinQueryWindowPos(frame->winhandle, &swp2); WinSetWindowPos(frame->winhandle, HWND_TOP, 0, 0, swp2.cx - cx, swp2.cy - y, SWP_SIZE | SWP_SHOW | SWP_ZORDER); SHORT res = SHORT1FROMMR(WinSendMsg(frame->frameWin->winhandle, WM_QUERYFRAMECTLCOUNT, 0, 0)); WinSendMsg(frame->frameWin->winhandle, WM_FORMATFRAME, MPFROMP(swp), 0); SHORT i; for (i = 0; i < res; i++) { if (swp[i].hwnd != 0) WinSetWindowPos(swp[i].hwnd, swp[i].hwndInsertBehind, swp[i].x, swp[i].y, swp[i].cx, swp[i].cy, swp[i].fl); } if (frame->clientWindow == NULL) WinInvalidateRegion(frame->winhandle, NULLHANDLE, TRUE); return TRUE; } else return FALSE; }
wxMenu* wxMenuBar::Remove( size_t nPos ) { wxMenu* pMenu = wxMenuBarBase::Remove(nPos); SHORT nId; if (!pMenu) return NULL; nId = SHORT1FROMMR(::WinSendMsg( (HWND)GetHmenu() ,MM_ITEMIDFROMPOSITION ,MPFROMSHORT(nPos) ,(MPARAM)0) ); if (nId == MIT_ERROR) { wxLogLastError(wxT("LogLastError")); return NULL; } if (IsAttached()) { ::WinSendMsg( (HWND)GetHmenu() ,MM_REMOVEITEM ,MPFROM2SHORT(nId, TRUE) ,(MPARAM)0 ); #if wxUSE_ACCEL if (pMenu->HasAccels()) { // // Need to rebuild accell table // RebuildAccelTable(); } #endif // wxUSE_ACCEL Refresh(); } m_titles.RemoveAt(nPos); return pMenu; } // end of wxMenuBar::Remove
MRESULT SetRightVolume(USHORT DevID, MPARAM mp1, MPARAM mp2) { USHORT NewVolume, VolumeScaled; BOOL bResult; if ( ( SHORT2FROMMP(mp1) == SLN_CHANGE || SHORT2FROMMP(mp1) == SLN_SLIDERTRACK ) && ! SliderSet ) { NewVolume = SHORT1FROMMR(WinSendMsg(hwndVolumeRight, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE), NULL)); if ( NewVolume != OldVolRight ) { VolumeScaled = ScaleValue(NewVolume, VolSliderPixels-1, 100); if ( ! VolChannelIndependent ) { CurrVolLeft = VolumeScaled; CurrVolRight = VolumeScaled; OldVolLeft = OldVolRight = NewVolume; SliderSet = TRUE; WinSendMsg(hwndVolumeLeft, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE), MPFROMSHORT(NewVolume)); SliderSet = FALSE; bResult = CDSetVolume(DevID, VolumeScaled, VolumeScaled); // CDOptError(bResult, hwnd, ERR_DEVICE_SETVOLUME); } else { CurrVolRight = VolumeScaled; OldVolRight = NewVolume; bResult = CDSetVolume(DevID, -1, VolumeScaled); // CDOptError(bResult, hwnd, ERR_DEVICE_SETVOLUME); } if ( SaveVolume ) { bResult = CDPrfSaveVolume(CurrVolLeft, CurrVolRight); } } } return NULL; }
wxMenu* wxMenuBar::Replace( size_t nPos , wxMenu* pMenu , const wxString& rTitle ) { SHORT nId; wxString sTitle = wxPMTextToLabel(rTitle); wxMenu* pMenuOld = wxMenuBarBase::Replace( nPos ,pMenu ,sTitle ); nId = SHORT1FROMMR(::WinSendMsg((HWND)m_hMenu, MM_ITEMIDFROMPOSITION, MPFROMSHORT(nPos), (MPARAM)0)); if (nId == MIT_ERROR) { wxLogLastError(wxT("LogLastError")); return NULL; } if (!pMenuOld) return NULL; m_titles[nPos] = sTitle; if (IsAttached()) { ::WinSendMsg((HWND)m_hMenu, MM_REMOVEITEM, MPFROM2SHORT(nId, TRUE), (MPARAM)0); ::WinSendMsg((HWND)m_hMenu, MM_INSERTITEM, (MPARAM)&pMenu->m_vMenuData, (MPARAM)sTitle.wx_str()); #if wxUSE_ACCEL if (pMenuOld->HasAccels() || pMenu->HasAccels()) { // // Need to rebuild accell table // RebuildAccelTable(); } #endif // wxUSE_ACCEL Refresh(); } return pMenuOld; } // end of wxMenuBar::Replace
// // NB: we don't support owner drawn top level items for now, if we do these // functions would have to be changed to use wxMenuItem as well // void wxMenuBar::EnableTop( size_t nPos , bool bEnable ) { wxCHECK_RET(IsAttached(), wxT("doesn't work with unattached menubars")); USHORT uFlag = 0; SHORT nId; if(!bEnable) uFlag = MIA_DISABLED; nId = SHORT1FROMMR(::WinSendMsg((HWND)m_hMenu, MM_ITEMIDFROMPOSITION, MPFROMSHORT(nPos), (MPARAM)0)); if (nId == MIT_ERROR) { wxLogLastError(wxT("LogLastError")); return; } ::WinSendMsg((HWND)m_hMenu, MM_SETITEMATTR, MPFROM2SHORT(nId, TRUE), MPFROM2SHORT(MIA_DISABLED, uFlag)); Refresh(); } // end of wxMenuBar::EnableTop
void DrvInitEjectAllDlg( HWND hwnd, MPARAM mp2) { SHORT ndx; HWND hList; ULONG ctr; ULONG cntDrives = 0; char achDrives[CAM_MAXMSD+1]; char szText[256]; cntDrives = DrvMapDrives( achDrives); if (cntDrives) cntDrives = DrvValidateDrives( achDrives, cntDrives); if (!cntDrives) { WindowClosed( WinQueryWindowUShort( hwnd, QWS_ID)); WinDestroyWindow( hwnd); return; } LoadDlgStrings( hwnd, nlsEjectAllDlg); hList = WinWindowFromID( hwnd, IDC_CAMLIST); for (ctr = 0; ctr < CAM_MAXMSD && achDrives[ctr]; ctr++) { DrvGetDriveName( achDrives[ctr], szText); ndx = SHORT1FROMMR( WinSendMsg( hList, LM_INSERTITEM, (MP)LIT_END, (MP)szText)); WinSendMsg( hList, LM_SETITEMHANDLE, MPFROM2SHORT( ndx, 0), MPFROM2SHORT( achDrives[ctr], 0)); WinSendMsg( hList, LM_SELECTITEM, MPFROM2SHORT( ndx, 0), (MP)TRUE); } ShowDialog( hwnd, CAMINI_EJECTPOS); if (CAMDRV_IS_ALWAYSEJECT) WinPostMsg( hwnd, WM_COMMAND, (MP)IDC_YES, 0); return; }
MRESULT hia_wmControl(HWND hwnd,MPARAM mp1,MPARAM mp2) { HIA *hia = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE); USHORT id = SHORT1FROMMP( mp1 ); USHORT notifyCode = SHORT2FROMMP( mp1 ); switch( id ) { case IDHCHLB_HANJASEL : case IDHCHLB_SPECIALCHARSEL : { SHORT index = SHORT1FROMMP( mp2 ); if( notifyCode == HCHLN_ENTER ) { if( index != HCHLIT_NONE ) { HANCHAR hch = SHORT1FROMMR( WinSendMsg( hia->hwndHCHLB, HCHLM_QUERYHCH, MPFROMSHORT( index ), 0 )); if( id == IDHCHLB_HANJASEL ) WinSendMsg( hwnd, HIAM_CANCELBUF, 0, 0 ); else hia->scselIndex = index; HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROM2SHORT(hch,0)); HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(hch,0)); } else if( id == IDHCHLB_HANJASEL ) WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 ); hia_destroyHCHLB( hia ); } break; } } return 0; }
void wxMenuBar::SetMenuLabel( size_t nPos , const wxString& rLabel ) { SHORT nId; MENUITEM vItem; wxCHECK_RET(nPos < GetMenuCount(), wxT("invalid menu index")); m_titles[nPos] = rLabel; if (!IsAttached()) { return; } nId = SHORT1FROMMR(::WinSendMsg((HWND)m_hMenu, MM_ITEMIDFROMPOSITION, MPFROMSHORT(nPos), (MPARAM)0)); if (nId == MIT_ERROR) { wxLogLastError(wxT("LogLastError")); return; } if(!::WinSendMsg( (HWND)m_hMenu ,MM_QUERYITEM ,MPFROM2SHORT(nId, TRUE) ,MPARAM(&vItem) )) { wxLogLastError(wxT("QueryItem")); } nId = vItem.id; if (::WinSendMsg(GetHmenu(), MM_SETITEMTEXT, MPFROMSHORT(nId), (MPARAM)rLabel.wx_str())); { wxLogLastError(wxT("ModifyMenu")); } Refresh(); } // end of wxMenuBar::SetMenuLabel
/*����������������������������������������������������������������������������*/ MSG_COLOR GetColor( HWND hwnd, PSPY_DATA pSpyData ) { /*������������������������������������������������������������������������Ŀ*/ /*� Get currently selected "color" from the list �*/ /*��������������������������������������������������������������������������*/ USHORT curItem = SHORT1FROMMR(WinSendDlgItemMsg(hwnd, ID_LB_COLORS, LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), NULL) ); /*������������������������������������������������������������������������Ŀ*/ /*� The first "color" in the list is the "Leave ASIS" item �*/ /*��������������������������������������������������������������������������*/ MSG_COLOR msgColor = (MSG_COLOR) ( (curItem == 0) ? Color_Asis : pSpyData->LogicalColorTranslation[curItem - 1].pbValue ); return( msgColor ); }
/*--------------------------------------------------------------------------- CmdAccum ---------------------------------------------------------------------------*/ void CmdAccum( WNDATTR *wndattr ) { MRESULT mres; HWND wnd; USHORT state; mres = WinSendMsg( Popup, MM_QUERYITEMATTR, MPFROMSHORT( CMD_ACCUM ), MPFROMSHORT( MIA_CHECKED ) ); state = SHORT1FROMMR( mres ); if (state != MIA_CHECKED) wnd = wndattr->Client; else wnd = NULLHANDLE; WinOpenClipbrd( wndattr->hab ); WinSetClipbrdViewer( wndattr->hab, wnd ); WinCloseClipbrd( wndattr->hab ); return; }
/* This Proc handles the ISO image mounting */ MRESULT EXPENTRY unmountIsoDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { char text[CCHMAXPATH]; char title[CCHMAXPATH]; ULONG rc; SWCNTRL swctl; PID pid; switch (msg) { case WM_INITDLG: { BOOL bDone=FALSE; int i; writeLog("Initializing dialog...\n"); /* Add switch entry */ memset(&swctl,0,sizeof(swctl)); WinQueryWindowProcess(hwnd,&pid,NULL); swctl.hwnd=hwnd; swctl.uchVisibility=SWL_VISIBLE; swctl.idProcess=pid; swctl.bProgType=PROG_DEFAULT; swctl.fbJump=SWL_JUMPABLE; WinAddSwitchEntry(&swctl); /*sprintf(text,"%d",params[4]);*/ // sprintf(text,"params[1]: %s ",params[1]); /* WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, pvSharedMem, params[4], 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); WinPostMsg(hwnd,WM_CLOSE,0,0); return (MRESULT) TRUE; */ /* Get free drive letters */ if((rc=DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap))!=NO_ERROR) WinPostMsg(hwnd,WM_CLOSE,0,0); DosError(FERR_DISABLEHARDERR); for(i=2;i<26;i++) { if(( (ulDriveMap << (31-i)) >>31)) { char chrDrive[3]="A:"; BYTE fsqBuf2[sizeof(FSQBUFFER2)+3*CCHMAXPATH]={0}; PFSQBUFFER2 pfsqBuf2=(PFSQBUFFER2) &fsqBuf2; ULONG ulLength; /* Get FS */ chrDrive[0]='A'+i; ulLength=sizeof(fsqBuf2); if(DosQueryFSAttach(chrDrive,0L,FSAIL_QUERYNAME, (PFSQBUFFER2)&fsqBuf2, &ulLength)==NO_ERROR) { if(!strcmp(pfsqBuf2->szName+pfsqBuf2->cbName+1,"ISOFS")) { FSINFO fsInfo; if(DosQueryFSInfo(i+1, FSIL_VOLSER, &fsInfo,sizeof(fsInfo))==NO_ERROR) sprintf(text, "%s (%s)",chrDrive, fsInfo.vol.szVolLabel); else sprintf(text, "%s (unknown)",chrDrive); WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_INSERTITEM,MPFROMSHORT(LIT_END),MPFROMP(text)); } } else printf("%s %s\n",chrDrive, "---"); } } DosError(FERR_ENABLEHARDERR); /* Set dialog font to WarpSans for Warp 4 and above */ if(cwQueryOSRelease()>=40) { WinSetPresParam(hwnd, PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT), DEFAULT_DIALOG_FONT ); } if(!bHaveWindowPos) WinSetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_ZORDER|SWP_ACTIVATE); else WinSetWindowPos(hwnd,HWND_TOP,swpWindow.x, swpWindow.y, 0, 0, SWP_MOVE|SWP_ZORDER|SWP_ACTIVATE|SWP_SHOW); return (MRESULT) TRUE; } case WM_CLOSE: WinQueryWindowPos(hwnd,&swpWindow); WinDismissDlg(hwnd,0); return FALSE; case WM_HELP: sendCommand("DISPLAYHELPPANEL=5100"); break; case WM_COMMAND: switch(SHORT1FROMMP(mp1)) { case IDPB_UNMOUNT: { /* User pressed the Unount button */ AEFS_DETACH detachparms={0}; char pszDrive[3]={0}; HOBJECT hObject; SHORT sSelected; memset(&detachparms, 0, sizeof(detachparms)); /* Get the drive letter */ sSelected=SHORT1FROMMR(WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST),MPFROMLONG(0L))); if(sSelected==LIT_NONE) break; WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_QUERYITEMTEXT, MPFROM2SHORT(sSelected,2),MPFROMP(pszDrive)); /* Send the attachment request to the FSD. */ rc = DosFSAttach( // (PSZ) "", (PSZ) pszDrive, (PSZ) AEFS_IFS_NAME, &detachparms, sizeof(detachparms), FS_DETACH); if (rc) { DosBeep(100,400); sprintf(text, "Error while unmounting rc=%d. Make sure there're no open files on the drive.\n", rc); WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, text, "ISO image unmount error", 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); }else { WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_DELETEITEM, MPFROMSHORT(sSelected),MPFROMLONG(0L)); sSelected=SHORT1FROMMR(WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_QUERYITEMCOUNT, MPFROMLONG(0L),MPFROMLONG(0L))); if(sSelected==0) WinEnableWindow(WinWindowFromID(hwnd,IDPB_UNMOUNT), FALSE); } break; } case IDPB_UNMOUNTCLOSE: WinPostMsg(hwnd,WM_CLOSE,0,0); break; default: break; } return (MRESULT) FALSE; default: break; } return WinDefDlgProc(hwnd, msg, mp1, mp2); }
SHORT winhInsertMenuItem( HWND hwndMenu, // in: menu to insert item into SHORT iPosition, // in: zero-based index of where to insert or MIT_END SHORT sItemId, // in: ID of new menu item const char *pcszItemTitle, // in: title of new menu item SHORT afStyle, // in: MIS_* style flags. // Valid menu item styles are: // -- MIS_SUBMENU // -- MIS_SEPARATOR // -- MIS_BITMAP: the display object is a bit map. // -- MIS_TEXT: the display object is a text string. // -- MIS_BUTTONSEPARATOR: // The item is a menu button. Any menu can have zero, // one, or two items of this type. These are the last // items in a menu and are automatically displayed after // a separator bar. The user cannot move the cursor to // these items, but can select them with the pointing // device or with the appropriate key. // -- MIS_BREAK: the item begins a new row or column. // -- MIS_BREAKSEPARATOR: // Same as MIS_BREAK, except that it draws a separator // between rows or columns of a pull-down menu. // This style can only be used within a submenu. // -- MIS_SYSCOMMAND: // menu posts a WM_SYSCOMMAND message rather than a // WM_COMMAND message. // -- MIS_OWNERDRAW: // WM_DRAWITEM and WM_MEASUREITEM notification messages // are sent to the owner to draw the item or determine its size. // -- MIS_HELP: // menu posts a WM_HELP message rather than a // WM_COMMAND message. // -- MIS_STATIC // This type of item exists for information purposes only. // It cannot be selected with the pointing device or // keyboard. SHORT afAttr, // in: MIA_* attribute flags // Valid menu item attributes (afAttr) are: // -- MIA_HILITED: if and only if, the item is selected. // -- MIA_CHECKED: a check mark appears next to the item (submenu only). // -- MIA_DISABLED: item is disabled and cannot be selected. // The item is drawn in a disabled state (gray). // -- MIA_FRAMED: a frame is drawn around the item (top-level menu only). // -- MIA_NODISMISS: // if the item is selected, the submenu remains down. A menu // with this attribute is not hidden until the application // or user explicitly does so, for example by selecting either // another menu on the action bar or by pressing the escape key. TASKDATA* data ) { MENUITEM mi; SHORT src = MIT_ERROR; mi.iPosition = iPosition; mi.afStyle = afStyle; mi.afAttribute = afAttr; mi.id = sItemId; mi.hwndSubMenu = 0; mi.hItem = (ULONG)data; src = SHORT1FROMMR( WinSendMsg( hwndMenu, MM_INSERTITEM, (MPARAM)&mi, (MPARAM)pcszItemTitle )); if( src != MIT_ERROR && src != MIT_MEMERROR ) { // If it is necessary the list of tasks is formatted to // several columns. RECTL item_rect; RECTL desk_rect; if( WinSendMsg( hwndMenu, MM_QUERYITEMRECT, MPFROM2SHORT( sItemId, FALSE ), MPFROMP(&item_rect)) && WinQueryWindowRect( HWND_DESKTOP, &desk_rect )) { int items = ( 0.80 * ( desk_rect.yTop - desk_rect.yBottom )) / ( item_rect.yTop - item_rect.yBottom ); if( src % items == 0 ) { mi.afStyle |= MIS_BREAKSEPARATOR; WinSendMsg( hwndMenu, MM_SETITEM, MPFROM2SHORT( 0, FALSE ), MPFROMP( &mi )); } } } return (src); }
void DumpDlgInfo( HWND hwndDlg ) { char szToUl[ 50 ]; int i; SHORT sItemIndex; HWND hwndLB; WinQueryDlgItemText( hwndDlg, CB_OPERATION, sizeof szToUl, szToUl ); for( i = 0; i < cOperations; i++ ) if( strcmp( szToUl, dcOperation[ i ].szItem ) == 0 ) { dlgInfo.usOperation = dcOperation[ i ].iItem; break; } if( i == cOperations ) dlgInfo.usOperation = atol( szToUl ); hwndLB = WinWindowFromID( hwndDlg, LB_CONTROL ); dlgInfo.fsControl = 0; sItemIndex = LIT_FIRST; do { sItemIndex = SHORT1FROMMR( WinSendMsg( hwndLB, LM_QUERYSELECTION, MPFROMSHORT( sItemIndex ), NULL ) ); if( sItemIndex != LIT_NONE ) dlgInfo.fsControl |= dcControl[ sItemIndex ].iItem; } while( sItemIndex != LIT_NONE ); hwndLB = WinWindowFromID( hwndDlg, LB_SUPPORTEDOPS ); dlgInfo.fsSupportedOps = 0; sItemIndex = LIT_FIRST; do { sItemIndex = SHORT1FROMMR( WinSendMsg( hwndLB, LM_QUERYSELECTION, MPFROMSHORT( sItemIndex ), NULL ) ); if( sItemIndex != LIT_NONE ) dlgInfo.fsSupportedOps |= dcSupportedOp[ sItemIndex ].iItem; } while( sItemIndex != LIT_NONE ); WinQueryDlgItemText( hwndDlg, EF_ITEMID, sizeof szToUl, szToUl ); dlgInfo.ulItemID = atol( szToUl ); WinQueryDlgItemText( hwndDlg, CB_TYPE, sizeof dlgInfo.szType, dlgInfo.szType ); for( i = 0; i < cTypes; i++ ) { if( !stricmp( ntsType[ i ].szName, dlgInfo.szType ) ) strcpy( dlgInfo.szType, ntsType[ i ].szString ); } WinQueryDlgItemText( hwndDlg, EF_CNR_NAME, sizeof dlgInfo.szContainerName, dlgInfo.szContainerName ); WinQueryDlgItemText( hwndDlg, EF_SOURCE_NAME, sizeof dlgInfo.szSourceName, dlgInfo.szSourceName ); WinQueryDlgItemText( hwndDlg, EF_TARGET_NAME, sizeof dlgInfo.szTargetName, dlgInfo.szTargetName ); dlgInfo.fUseDlgItemID = WinQueryButtonCheckstate( hwndDlg,CHK_OVERRIDE_ID ); dlgInfo.fUseDlgDragNames = WinQueryButtonCheckstate( hwndDlg, CHK_OVERRIDE_HSTRS ); }
/*@ XSettingButton :: IsSelected( void ) @group misc @remarks Query if a button is selected @returns BOOL result */ BOOL XSettingButton::IsSelected(void) const { return SHORT1FROMMR(WinSendMsg(winhandle, BM_QUERYCHECK, 0, 0)); }
// --------------------------------------------------------------------------- // Main Frame window proc // --------------------------------------------------------------------------- MRESULT EXPENTRY wxFrameMainWndProc( HWND hWnd, ULONG ulMsg, MPARAM wParam, MPARAM lParam ) { MRESULT rc = (MRESULT)0; bool bProcessed = false; wxFrame* pWnd = NULL; pWnd = (wxFrame*) wxFindWinFromHandle((WXHWND) hWnd); switch (ulMsg) { case WM_QUERYFRAMECTLCOUNT: if(pWnd && pWnd->m_fnOldWndProc) { USHORT uItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam)); rc = MRFROMSHORT(uItemCount); } break; case WM_FORMATFRAME: ///////////////////////////////////////////////////////////////////////////////// // Applications that subclass frame controls may find that the frame is already // subclassed the number of frame controls is variable. // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be // subclassed by calling the previous window procedure and modifying its result. //////////////////////////////////////////////////////////////////////////////// { int nItemCount; int i; PSWP pSWP = NULL; RECTL vRectl; RECTL vRstb; RECTL vRtlb; int nHeight = 0; int nHeight2 = 0; int nWidth = 0; pSWP = (PSWP)PVOIDFROMMP(wParam); nItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam)); if(pWnd->m_frameStatusBar) { ::WinQueryWindowRect(pWnd->m_frameStatusBar->GetHWND(), &vRstb); pWnd->m_frameStatusBar->GetSize(NULL, &nHeight); } if(pWnd->m_frameToolBar) { ::WinQueryWindowRect(pWnd->m_frameToolBar->GetHWND(), &vRtlb); pWnd->m_frameToolBar->GetSize(&nWidth, &nHeight2); } ::WinQueryWindowRect(pWnd->m_hFrame, &vRectl); ::WinMapWindowPoints(pWnd->m_hFrame, HWND_DESKTOP, (PPOINTL)&vRectl, 2); ::WinCalcFrameRect(pWnd->m_hFrame, &vRectl, TRUE); ::WinMapWindowPoints(HWND_DESKTOP, pWnd->m_hFrame, (PPOINTL)&vRectl, 2); for(i = 0; i < nItemCount; i++) { if(pWnd->m_hWnd && pSWP[i].hwnd == pWnd->m_hWnd) { if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_TOP) { pSWP[i].x = vRectl.xLeft; pSWP[i].y = vRectl.yBottom + nHeight; pSWP[i].cx = vRectl.xRight - vRectl.xLeft; pSWP[i].cy = vRectl.yTop - vRectl.yBottom - (nHeight + nHeight2); } else if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_BOTTOM) { pSWP[i].x = vRectl.xLeft; pSWP[i].y = vRectl.yBottom + nHeight + nHeight2; pSWP[i].cx = vRectl.xRight - vRectl.xLeft; pSWP[i].cy = vRectl.yTop - vRectl.yBottom - (nHeight + nHeight2); } else if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_LEFT) { pSWP[i].x = vRectl.xLeft + nWidth; pSWP[i].y = vRectl.yBottom + nHeight; pSWP[i].cx = vRectl.xRight - (vRectl.xLeft + nWidth); pSWP[i].cy = vRectl.yTop - vRectl.yBottom - nHeight; } else { pSWP[i].x = vRectl.xLeft; pSWP[i].y = vRectl.yBottom + nHeight; pSWP[i].cx = vRectl.xRight - (vRectl.xLeft + nWidth); pSWP[i].cy = vRectl.yTop - vRectl.yBottom - nHeight; } pSWP[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW; pSWP[i].hwndInsertBehind = HWND_TOP; } } bProcessed = true; rc = MRFROMSHORT(nItemCount); } break; default: if(pWnd && pWnd->m_fnOldWndProc) rc = pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam); else rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam); } return rc; } // end of wxFrameMainWndProc
/************************************************************************* * * Name : WinProc(hwnd, msg, mp1, mp2) * * Description: Processes the messages sent to the main client * window. This routine processes the basic * messages all client windows should process. * * Concepts : This procedure provides service routines for the general * PM events (messages) that PM sends to the window, as well * as the user initiated events (messages) that are generated * when the user selects the action bar and pulldown menu * controls or the corresponding keyboard accelerators. * * The switch statement shown below distributes the window * messages to the respective message service routines, which * are set apart by the case statements. The window * procedures must provide an appropriate service routine for * its end user initiated messages, as well as the general PM * messages (like the WM_CLOSE message). If a message is sent * to this procedure for which there is no programmed case * clause (i.e., no service routine), the message is defaulted * function WinDefWindowProc, where it is disposed of by PM. * * Time-consuming tasks are posted to the object window where * they can be performed without the 1/10 second turnaround * time imposed on the client window. When the object window * is busy, the client window is usually disabled. The object * window then posts an acknowledgement * back to the client when the lengthy task is completed. * * Cases under the big switch appear in alphabetical order. * * API's : WinLoadString * WinMessageBox * WinQueryWindowULong * WinSendMsg * WinPostMsg * WinIsWindowEnabled * WinSetPointer * WinQuerySysPointer * WinBeginPaint * WinQueryWindowRect * WinFillRect * WinEndPaint * WinInvalidateRect * WinSetWindowText * GpiDrawChain * GpiConvert * GpiSetDefaultViewMatrix * GpiAssociate * GpiDestroyPS * GpiDeleteBitmap * GpiDeleteMetafile * * Parameters : HWND window handle * ULONG message * MPARAM message parameter 1 * MPARAM message parameter 2 * * Result : MRESULT message result * *************************************************************************/ MRESULT EXPENTRY WinProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { BOOL bOK; PMAIN_PARM pmp; HPS hps; RECTL rectl; PSZ psz; CHAR szWork[ LEN_WORKSTRING ]; SHORT sStep; ULONG ulWork; SHORT sNewPos; ULONG rc; switch(msg) { case WM_CLOSE: /* obtain the main parameter pointer from window words */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); #ifdef OSA_AWARE /* Do OSA termination */ TerminateOSA(hwnd); #endif if( pmp->fBusy ) { /* OK to close when object window is busy? */ WinLoadString( pmp->hab, (HMODULE)NULLHANDLE, ERRMSG_CLOSE_QUESTION, LEN_WORKSTRING, szWork ); ulWork = WinMessageBox( HWND_DESKTOP, pmp->hwndFrame, szWork, pmp->pszTitle, (USHORT)0, MB_YESNOCANCEL | MB_MOVEABLE | MB_CUANOTIFICATION | MB_APPLMODAL); if( ulWork == MBID_YES ) { /* close down the application in spite of being busy */ pmp->fCancel = TRUE; /* disable client during exit */ WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0 , (MPARAM)0 ); /* start a watchdog timer to ensure a timely death */ WinStartTimer( pmp->hab, hwnd, ID_DEATH_TIMER, LEN_DEATH_TIMER ); /* Tell object window to close, quit, and post me a WM_QUIT */ WinPostMsg( pmp->hwndObject, WM_USER_CLOSE, (MPARAM)hwnd, (MPARAM)0 ); } } else { /* not busy, so initiate closure by telling object window to close */ WinPostMsg( pmp->hwndObject, WM_USER_CLOSE, (MPARAM)hwnd, (MPARAM)0 ); } return (MRESULT)NULL; case WM_COMMAND: /* do menu activities; see menu.c */ return Menu( hwnd, msg, mp1, mp2 ); case WM_CREATE: /* * Do one-time, startup processing in PRTCREAT.C. * This function allocates the pmp, a pointer to the program's * main parameters. See the declaration of this block of * parameters in PRTSAMP.H, the MAIN_PARM structure. * * The Create() function allocates this structure and * begins to initialize it. Throughout all the code, the pmp-> * pointer is usually obtainable with a call to WinQueryWindowULong. * Window word space for this pointer was reserved on the call * to WinRegisterClass. * * Create() allocates, initializes, and stores the pmp pointer * in the client window words. It then starts thread 2 of the * application on which the object window operates. The pmp * pointer is passed to thread 2 with _beginthread in PRTCREAT.C. * The pmp is passed to the object window on the call to * WinCreateWindow in PRTOBJ.C. Finally, the object window stores * the pmp in its window words under the WM_CREATE case of the * ObjectWinProc in PRTOBJ.C. * */ Create( hwnd ); #ifdef OSA_AWARE /* Do OSA Initialization */ InitOSA(hwnd); #endif #ifdef OSA_AWARE /* Generate a Apple Event - Open Application to myself (Workaround) */ rc = GenerateOSAEvent(hwnd, msg, MPFROMSHORT(IDM_AEOPENAPP), mp2); #endif return (MRESULT)NULL; case WM_HSCROLL: pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* Compute some fraction of scroll bar range for a unit of scrolling. */ sStep = pmp->sHScrollRange / 50; switch( SHORT2FROMMP( mp2 )) { case SB_LINELEFT: pmp->sHScrollPos -= sStep; break; case SB_PAGELEFT: pmp->sHScrollPos -= pmp->sizelClient.cx; break; case SB_LINERIGHT: pmp->sHScrollPos += sStep; break; case SB_PAGERIGHT: pmp->sHScrollPos += pmp->sizelClient.cx; break; case SB_SLIDERPOSITION: case SB_SLIDERTRACK: pmp->sHScrollPos = SHORT1FROMMP( mp2 ); break; } /* Don't allow step assignments to exceed limits of zero to range. */ pmp->sHScrollPos = max( (SHORT)0, min( pmp->sHScrollPos, pmp->sHScrollRange )); if( pmp->sHScrollPos != SHORT1FROMMR(WinSendMsg( pmp->hwndHScroll, SBM_QUERYPOS, (MPARAM)0, (MPARAM)0 ))) { /* * New scroll bar thumbbutton position is different than current. * Set a new X translation value to effect the scroll. * Current scale setting affects the X element of the matrix. */ pmp->matlfDefView.lM31 = OFFSET_XY_TWIPS - (LONG)(pmp->floatScale * (float)( pmp->sHScrollPos)); bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9, &pmp->matlfDefView, TRANSFORM_REPLACE ); pmassert( pmp->hab, bOK ); CalibrateHorizontalScrollBar( pmp ); WinInvalidateRect( hwnd, NULL, FALSE ); } return (MRESULT) 0; case WM_MOUSEMOVE: /* display which pointer? -- could query pmp->fBusy or... */ if( WinIsWindowEnabled( hwnd )) { /* not disabled; display regular pointer */ WinSetPointer( HWND_DESKTOP, WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE )); } else { /* disabled; display hourglass because I'm busy */ WinSetPointer( HWND_DESKTOP, WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE )); } return (MRESULT) 1; case WM_NACK_BITMAP_NOT_SUPPORTED: /* * Object window does not support this format of bitmap - * show a message box. */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); bOK = WinLoadString( pmp->hab, (HMODULE)0, ERRMSG_BITMAP_NOT_SUPPORTED, LEN_WORKSTRING, szWork ); pmassert( pmp->hab, bOK ); WinMessageBox( HWND_DESKTOP, pmp->hwndFrame, szWork, pmp->pszTitle, (USHORT)0, MB_OK | MB_MOVEABLE | MB_CUACRITICAL | MB_APPLMODAL); pmp->ulNextMode = MODE_UNKNOWN; pmp->szNextFilename[0] = 0; WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 ); return (MRESULT) 0; case WM_NACK_BITMAP_ERROR: /* * Object window had error loading the bitmap file - * show a message box */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); bOK = WinLoadString( pmp->hab, (HMODULE)NULLHANDLE, ERRMSG_BAD_BITMAP, LEN_WORKSTRING, szWork ); pmassert( pmp->hab, bOK ); WinMessageBox( HWND_DESKTOP, pmp->hwndFrame, szWork, pmp->pszTitle, (USHORT)0, MB_OK | MB_MOVEABLE | MB_CUAWARNING | MB_APPLMODAL); pmp->ulNextMode = MODE_UNKNOWN; pmp->szNextFilename[0] = 0; WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 ); return (MRESULT) 0; case WM_NACK_FILE_READING_ERROR: /* * Object window had a problem with reading the disk - * show a message box. */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); bOK = WinLoadString( pmp->hab, (HMODULE)NULLHANDLE, ERRMSG_READ_ERROR, LEN_WORKSTRING, szWork ); pmassert( pmp->hab, bOK ); WinMessageBox( HWND_DESKTOP, pmp->hwndFrame, szWork, pmp->pszTitle, (USHORT)0, MB_OK | MB_MOVEABLE | MB_CUACRITICAL | MB_APPLMODAL); pmp->ulNextMode = MODE_UNKNOWN; pmp->szNextFilename[0] = 0; WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 ); return (MRESULT) 0; case WM_PAINT: pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* do not rely on client window rectangle being correct */ WinQueryUpdateRect( hwnd, &rectl ); WinQueryWindowRect( hwnd, &rectl ); /* current mode of the program affects window painting */ switch( pmp->ulMode ) { case MODE_UNKNOWN: WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); WinPostMsg( pmp->hwndObject, WM_USER_PAINT_DEFAULT_SCREEN, (MPARAM)hwnd, (MPARAM)0 ); /* must call default window proc for window validation */ break; case MODE_TEXT: if( pmp->fBusy ) { /* * Object window is busy with the client PS drawing into * retained segments. Use a cached micro PS to merely * fill the client window with a background wash. * * Proper painting of the text will occur in due time * because the WM_USER_ACK case below will * invalidate the client window and force a paint. * The object window won't be busy then. */ hps = WinBeginPaint( hwnd, (HPS) 0, &rectl ); pmassert( pmp->hab, hps ); bOK = WinFillRect( hps, &rectl, SYSCLR_WINDOW ); pmassert( pmp->hab, bOK ); WinEndPaint( hps ); } else { /* PS not busy. Use GpiDrawChain to repaint the text */ hps = WinBeginPaint( hwnd, (HPS)pmp->hpsClient, &rectl ); pmassert( pmp->hab, hps ); bOK = WinFillRect( pmp->hpsClient, &rectl, SYSCLR_WINDOW ); pmassert( pmp->hab, bOK ); /* * GpiDrawChain re-plays the GpiCharString orders that were * retain in the WM_USER_PAGINATE case in prtobj.c */ bOK = GpiDrawChain( pmp->hpsClient ); pmassert( pmp->hab, bOK ); bOK = WinEndPaint( pmp->hpsClient ); pmassert( pmp->hab, bOK ); } return (MRESULT) 0; case MODE_BITMAP: if( pmp->hbm ) { WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); WinPostMsg( pmp->hwndObject, WM_USER_PAINT_BITMAP, (MPARAM)hwnd, (MPARAM)0 ); } /* must call default window proc for window validation */ break; case MODE_METAFILE: hps = WinBeginPaint( hwnd, (HPS) 0, &rectl ); pmassert( pmp->hab, hps ); WinFillRect( hps, &rectl, SYSCLR_WINDOW ); if( pmp->hmf ) { WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); WinPostMsg( pmp->hwndObject, WM_USER_PAINT_METAFILE, (MPARAM)hwnd, (MPARAM)0 ); } WinEndPaint( hps ); return (MRESULT) 0; default: pmassert( pmp->hab, NULL == "bad case in WM_PAINT" ); } break; #ifdef OSA_AWARE case WM_SEMANTICEVENT: /* Handle Apple Event Manager Semantic Event */ WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "WM_SEMANTIC_EVENT was received", "WinProc", (USHORT)0, MB_OK | MB_NOICON); /* Call ProcessSemanticEvent to process the Apple Event */ ProcessSemanticEvent( hwnd, msg, mp1, mp2 ); return (MRESULT) 0; #endif case WM_SIZE: /* Do size process if frame is not minimized */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* * If the object window is busy drawing, the GPI calls here can fail * because the PS is busy. Check for this situation and delay * the sizing operation by a few milliseconds. */ if( pmp->fBusy ) { WinStartTimer( pmp->hab, hwnd, ID_SIZE_TIMER, LEN_SIZE_TIMER ); return (MRESULT) 0; } ulWork = WinQueryWindowULong( pmp->hwndFrame, QWL_STYLE ); if( !( ulWork & WS_MINIMIZED )) { /* Frame is not minimized. Get window size in pels. */ WinQueryWindowRect( hwnd, &rectl ); /* how many twips will fit into the client window now? */ bOK = GpiConvert( pmp->hpsClient, CVTC_DEVICE, CVTC_WORLD, 2L, (PPOINTL)&rectl ); pmassert( pmp->hab, bOK ); /* compute client size in twips, store in pmp */ pmp->sizelClient.cx = rectl.xRight - rectl.xLeft; pmp->sizelClient.cy = rectl.yTop - rectl.yBottom; /* Try to keep the current position still in view by calculating */ /* the difference between size required and client window. */ /* The scroll position is then either 0 or the minimum of the */ /* difference and the old scroll position */ sNewPos = (LONG)FixedInchesToTwips(pmp->form.fxxWidth) + (((float)(2 * OFFSET_XY_TWIPS)) / pmp->floatScale) - pmp->sizelClient.cx; pmp->sHScrollPos = min( max( 0, sNewPos), pmp->sHScrollPos); sNewPos = (LONG)FixedInchesToTwips(pmp->form.fxyHeight) + (((float)(2 * OFFSET_XY_TWIPS)) / pmp->floatScale) - pmp->sizelClient.cy; pmp->sVScrollPos = min( max( 0, sNewPos), pmp->sVScrollPos); /* recalibrate the scroll bars */ CalibrateHorizontalScrollBar( pmp ); CalibrateVerticalScrollBar( pmp ); /* * Modify def-view matrix translation to home the displayed page. * This depends on the current scaling value. */ pmp->matlfDefView.lM31 = OFFSET_XY_TWIPS - (LONG)(pmp->floatScale * (float)( pmp->sHScrollPos)); pmp->matlfDefView.lM32 = OFFSET_XY_TWIPS + (LONG)(pmp->floatScale * (float)( pmp->sVScrollPos - pmp->sVScrollRange )); bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9, &pmp->matlfDefView, TRANSFORM_REPLACE ); pmassert( pmp->hab, bOK ); /* force a paint */ WinInvalidateRect( hwnd, NULL, FALSE ); } return (MRESULT) 0; case WM_TIMER: pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); switch( (ULONG) mp1 ) { case ID_DEATH_TIMER: /* object window never posted a quit in allotted time. WinPostMsg( hwnd, WM_QUIT, 0, 0 ); break; case ID_SIZE_TIMER: /* object window was busy with the PS before; try sizing now */ bOK = WinStopTimer( pmp->hab, hwnd, ID_SIZE_TIMER ); pmassert( pmp->hab, bOK ); WinSendMsg( hwnd, WM_SIZE, 0, 0 ); break; } return (MRESULT) 0; case WM_USER_ACK: /* * Object window is done processing lengthy task. * mp1 contains the WM_USER msg originally posted to the object window * mp2 may contain a result code, depending on mp1 */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* reenable the client window */ WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); switch( (ULONG)mp1 ) { case WM_USER_LOAD_BITMAP: case WM_USER_LOAD_METAFILE: case WM_USER_LOAD_TEXT: /* * Do size processing so that document will * "home" in the client window. */ WinSendMsg( hwnd, WM_SIZE, (MPARAM)0, (MPARAM)0 ); break; case WM_USER_PAGINATE: switch( (ULONG)mp2 ) { case PAGINATE_EOF: case PAGINATE_EOF_PART_PAGE: /* seek top of file */ fseek( pmp->f, 0, SEEK_SET ); } WinInvalidateRect( hwnd, NULL, FALSE ); break; } return (MRESULT) 0; case WM_USER_DISABLE_CLIENT: /* * usually disable before posting a task to the object window * this message may be sent; disable menu action bar as well */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); pmp->fBusy = TRUE; WinEnableWindow( pmp->hwndClient, FALSE ); WinEnableWindow( pmp->hwndMenubar, FALSE ); WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL, FALSE ); WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL, FALSE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, FALSE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, FALSE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, FALSE ); return (MRESULT)0; case WM_USER_ENABLE_CLIENT: /* * usually enable upon receipt of object window ack/nack * this message may be sent; enable menu actions if text mode */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); pmp->fBusy = FALSE; WinEnableWindow( pmp->hwndClient, TRUE ); WinEnableWindow( pmp->hwndMenubar, TRUE ); WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL, TRUE ); WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL, TRUE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, TRUE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, TRUE ); if( pmp->ulMode == MODE_TEXT ) { WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, TRUE ); } return (MRESULT) 0; case WM_USER_NEW_MODE: /* * The program now has a new file, file type, or printer, or * printer form, orientation, resolution, etc. The receipt * and processing of this message works to reset the program: * Old file, bitmap, or metafile handles are closed, and * new ones get opened. The titlebar shows the new filename. * This case works very much like a program reset. */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* close processing on current file */ switch( pmp->ulMode ) { case MODE_BITMAP: /* destroy previous memory dc, ps, and hbm */ if( pmp->hpsMemory ) { GpiAssociate( pmp->hpsMemory, (HDC)0 ); GpiDestroyPS( pmp->hpsMemory ); pmp->hpsMemory = (HPS) 0; } if( pmp->hdcMemory ) { DevCloseDC( pmp->hdcMemory ); pmp->hdcMemory = (HDC) 0; } if( pmp->hbm ) { GpiDeleteBitmap( pmp->hbm ); pmp->hbm = (HBITMAP) 0; } break; case MODE_METAFILE: /* destroy old metafile handle */ if( pmp->hmf ) { GpiDeleteMetaFile( pmp->hmf ); pmp->hmf = (HMF) 0; } break; case MODE_TEXT: fclose( pmp->f ); pmp->f = (FILE *) 0; /* turn off options for text mode */ WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, FALSE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_SETFONT, FALSE ); break; } /* turn off options for all modes */ WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, FALSE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, FALSE ); WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL, FALSE ); WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL, FALSE ); /* copy over current values with the next values */ pmp->ulMode = pmp->ulNextMode; strcpy( pmp->szFilename, pmp->szNextFilename ); /* enable the print menu option if mode is known and there is a printer set up. */ WinEnableMenuItem( pmp->hwndMenubar, IDM_PRINT, (pmp->ulMode != MODE_UNKNOWN && pmp->hpsPrinterInfo ) ); /* update title bar text and show filename in use */ if( *pmp->szFilename ) { /* parse full-qualified filename to just get filename and extension */ psz = strrchr( pmp->szFilename, '\\' ); if (psz && *psz) { ++psz; } else { psz = pmp->szFilename; } sprintf( szWork, "%s - %s", pmp->pszTitle, psz ); } else { strcpy( szWork, pmp->pszTitle ); } WinSetWindowText( pmp->hwndTitlebar, szWork ); /* enable options for all modes */ WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, TRUE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, TRUE ); WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL, TRUE ); WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL, TRUE ); /* process this new mode */ switch( pmp->ulMode ) { case MODE_BITMAP: /* load the bitmap into memory so it is compatible with the screen */ WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 ); WinPostMsg( pmp->hwndObject, WM_USER_LOAD_BITMAP, (MPARAM)hwnd, (MPARAM)FLAGS_SCREEN ); break; case MODE_METAFILE: /* make object window read metafile */ WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 ); WinPostMsg( pmp->hwndObject, WM_USER_LOAD_METAFILE, (MPARAM)hwnd, 0 ); break; case MODE_TEXT: /* turn on options for text mode */ WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, TRUE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_SETFONT, TRUE ); /* reset view matrix that was last in effect for viewing text pages; */ /* this gets lost after viewing a metafile */ bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9, &pmp->matlfDefView, TRANSFORM_REPLACE ); pmassert( pmp->hab, bOK ); /* disable until text loaded */ WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 ); /* tell object window to load the text file */ bOK = WinPostMsg( pmp->hwndObject, WM_USER_LOAD_TEXT, (MPARAM)hwnd, 0 ); pmassert( pmp->hab, bOK ); break; case MODE_UNKNOWN: /* size screen to get correct scrollbars */ WinPostMsg( pmp->hwndClient, WM_SIZE, 0, 0 ); break; } return (MRESULT) 0; case WM_VSCROLL: pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* Compute some fraction of scroll bar range for a unit of scrolling. */ sStep = pmp->sVScrollRange / 50; switch( SHORT2FROMMP( mp2 )) { case SB_LINEUP: pmp->sVScrollPos -= sStep; break; case SB_PAGEUP: pmp->sVScrollPos -= pmp->sizelClient.cy; break; case SB_LINEDOWN: pmp->sVScrollPos += sStep; break; case SB_PAGEDOWN: pmp->sVScrollPos += pmp->sizelClient.cy; break; case SB_SLIDERPOSITION: case SB_SLIDERTRACK: sNewPos = SHORT1FROMMP( mp2 ); pmp->sVScrollPos = sNewPos; break; } /* Don't allow step assignments to exceed limits of zero to range. */ pmp->sVScrollPos = max( (SHORT)0, min( pmp->sVScrollPos, pmp->sVScrollRange )); if( pmp->sVScrollPos != SHORT1FROMMR(WinSendMsg( pmp->hwndVScroll, SBM_QUERYPOS, (MPARAM)0, (MPARAM)0 ))) { /* * New scroll bar thumbbutton position is different than current. * Set a new Y translation value to effect the scroll. * Current scale setting affects the Y element of the matrix. */ pmp->matlfDefView.lM32 = OFFSET_XY_TWIPS + (LONG)(pmp->floatScale * (float)( pmp->sVScrollPos - pmp->sVScrollRange )); pmp->matlfDefView.lM32 = (LONG)(pmp->floatScale * (float)( OFFSET_XY_TWIPS + pmp->sVScrollPos - pmp->sVScrollRange )); bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9, &pmp->matlfDefView, TRANSFORM_REPLACE ); pmassert( pmp->hab, bOK ); CalibrateVerticalScrollBar( pmp ); WinInvalidateRect( hwnd, NULL, FALSE ); } return (MRESULT) 0; } return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } /* End of WinProc */
MRESULT IntrospectBase::DlgProc(ULONG msg, MPARAM mp1, MPARAM mp2) { switch (msg) {case WM_INITDLG: { MRESULT ret = DialogBase::DlgProc(msg, mp1, mp2); do_warpsans(GetHwnd()); // Populate MRU list ComboBox cb(GetCtrl(CB_SERVER)); if (Configuration.SinkServer) cb.InsertItem(Configuration.SinkServer); char key[] = "Server1"; do { xstring url; ini_query(key, url); if (!url) break; cb.InsertItem(url); } while (++key[sizeof key -2] <= '9'); return ret; } case WM_COMMAND: DEBUGLOG(("IntrospectBase::DlgProc:WM_COMMAND(%i,%i, %p)\n", SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), mp2)); switch (SHORT1FROMMP(mp1)) {case PB_UPDATE: PostMsg(UM_CONNECT, 0,0); return 0; case DID_OK: { ComboBox cb(GetCtrl(CB_SERVER)); const xstring& server = cb.Text(); // update MRU list if (server.length()) { char key[] = "Server1"; int i = 0; int len = 0; xstring url; do { if (len >= 0) {skip: url.reset(); len = (SHORT)SHORT1FROMMR(WinSendMsg(cb.Hwnd, LM_QUERYITEMTEXTLENGTH, MPFROMSHORT(i), 0)); if (len >= 0) { WinSendMsg(cb.Hwnd, LM_QUERYITEMTEXT, MPFROM2SHORT(i, len+1), MPFROMP(url.allocate(len))); DEBUGLOG(("IntrospectBase::DlgProc: save MRU %i: (%i) %s\n", i, len, url.cdata())); ++i; if (url == server) goto skip; } } ini_write(key, url); } while (++key[sizeof key -2] <= '9'); } Configuration.Save(); } break; } break; case WM_CONTROL: switch (SHORT1FROMMP(mp1)) {case CB_SERVER: switch (SHORT2FROMMP(mp1)) {case CBN_ENTER: PostMsg(UM_CONNECT, 0,0); break; } break; case CB_SINKSRC: switch (SHORT2FROMMP(mp1)) {case CBN_ENTER: PostMsg(UM_UPDATE_PORT, 0,0); break; } } break; case UM_CONNECT: { DEBUGLOG(("IntrospectBase::DlgProc:UM_CONNECT\n")); // destroy any old connection Cleanup(); const xstring& server = WinQueryDlgItemXText(GetHwnd(), CB_SERVER); if (!server.length()) { WinSetDlgItemText(GetHwnd(), ST_STATUS, "enter server name above"); return 0; } // open new connection try { Context.Connect("PM123", server); } catch (const PAException& ex) { WinSetDlgItemText(GetHwnd(), ST_STATUS, ex.GetMessage()); } return 0; } case UM_STATE_CHANGE: { pa_context_state_t state = (pa_context_state_t)LONGFROMMP(mp1); DEBUGLOG(("IntrospectBase::DlgProc:UM_STATE_CHANGE %u\n", state)); const char* text = ""; switch (state) {case PA_CONTEXT_CONNECTING: text = "Connecting ..."; break; case PA_CONTEXT_AUTHORIZING: text = "Authorizing ..."; break; case PA_CONTEXT_SETTING_NAME: text = "Set name ..."; break; case PA_CONTEXT_READY: text = "Connected"; PostMsg(UM_DISCOVER_SERVER, 0,0); break; case PA_CONTEXT_FAILED: WinSetDlgItemText(GetHwnd(), ST_STATUS, PAConnectException(Context.GetContext()).GetMessage()); return 0; case PA_CONTEXT_TERMINATED: text = "Closed"; break; case PA_CONTEXT_UNCONNECTED:; } WinSetDlgItemText(GetHwnd(), ST_STATUS, text); return 0; } } return DialogBase::DlgProc(msg, mp1, mp2); }