Hello What i mean is i want ot select the button on the dialog box and move it along with my mouse and place it on the other button which is also on the current dialog box only and when i place likethat the two buttons should get swaped in there location first of all i am notget the handler of the button on the dialog box i am using GetActiveWindow(); GetWindowRect(); GetClientREct(); non of them are giving me the handle to my button or the coordinates ofthe button plz suggest me some idea Request to all to continue this
Tripura K
Posts
-
VC++ abt buttons -
VC++ abt buttonsCan any one of you tell me how to swap two buttons which are placed on and Dialog box which is MDI based application and the buttons are owner draw buttons kindly suggest me some idea Request to all to continue this
-
ownderdrawhi everybody, Can any one of u help me to brushing on a ownder draw button I have few owner draw buttons on a dialogbox which is created in an SDI application and now i want to change the color of the buttons can any one tell me what code do i need to write for that my code is as follow void MybutCls::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { ::DrawFrameControl(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, DFC_BUTTON,DFCS_BUTTONPUSH|BS_DEFPUSHBUTTON); //what should i add here if(((0x8000 ==(0x8000 & GetKeyState(16))&& !caps)) || ((0x8000 ==(0x8000 & GetKeyState(16))&& caps))) { if(lpDrawItemStruct->CtlID==IDC_BUTTON49) ::DrawText(lpDrawItemStruct->hDC,"!",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON45) ::DrawText(lpDrawItemStruct->hDC,"_",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON39 ) ::DrawText(lpDrawItemStruct->hDC,"\"",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON44) ::DrawText(lpDrawItemStruct->hDC,"<",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON46) ::DrawText(lpDrawItemStruct->hDC,">",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON47) ::DrawText(lpDrawItemStruct->hDC,"?",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON48) ::DrawText(lpDrawItemStruct->hDC,")",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON50) ::DrawText(lpDrawItemStruct->hDC,"@",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON51) ::DrawText(lpDrawItemStruct->hDC,"#",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON52) ::DrawText(lpDrawItemStruct->hDC,"$",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON53) ::DrawText(lpDrawItemStruct->hDC,"%",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON54) ::DrawText(lpDrawItemStruct->hDC,"^",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON55) ::DrawText(lpDrawItemStruct->hDC,"&",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENT
-
On-Screen KeyboardHi all, Instead of creting the buttons if i drag and drog the buttons and make them ownerdraw on the dialog box and and try to sendthe messages to the background applications the sequence in which the keystroke generate shold be WM_KEYDOWN ->WM_CHAR->WM_KEYUP but its coming as WM_KEYDOWN->WM_KEYUP-> WM_CHAR for me for the following code can any one help me void MyDialog::GenerateKeyStroke(UINT nVirtualKeyCode) { CMainWindow *pView= (CMainWindow*)GetParent(); LPARAM lParam; lParam = MapVirtualKey(nVirtualKeyCode, 0) ; //scan code are from 16-23 in lparam lParam <<= 16; //since repeat count is one lParam++; pView->PostMessage(WM_KEYDOWN , nVirtualKeyCode , lParam ) ; lParam |= 0xC0000000; Sleep(0); pView->PostMessage(WM_KEYUP , nVirtualKeyCode , lParam ) ; } and I shold use only PostMessage can any one help adn if press Alt key System keyevents should generate for me what should i do for that Request to all to continue this
-
buttin VC++Hi all I have a modeless dialogbox which is created in a SDI applic on which i have few ownerdraw buttons on one button i have written F4 and my requirement is when ever i click alt key on the keyboard along woth F4 button on the dialog About dialog box of EditView should open , what all messages do i need to send to my application to gennerate this event, i am making use of pretranslate message to check if the alt key is pressed on the key board void MyDialog::OnButtonF4() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); if(0x8000 ==(0x8000 & GetKeyState(18))) { pView->SendMessage(WM_SYSKEYDOWN, 18, 1); pView->SendMessage(WM_SYSKEYDOWN, 115, 1); pView->SendMessage(WM_SYSKEYUP, 115, 1); pView->SendMessage(WM_KEYUP, 18, 1); } } BOOL MyDialog::PreTranslateMessage(MSG* pMsg) { if( pMsg->message == WM_SYSKEYDOWN && pMsg->wParam == 18) { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_SYSKEYDOWN,18,0); } if( pMsg->message == WM_SYSKEYUP && pMsg->wParam == 18) { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_KEYUP,18,0); } return CDialog::PreTranslateMessage(pMsg); } can any one help me what to write in Alt key fuction or F4 func or in PreTranslte message Request to all to continue this
-
small doubtHi all i have void MyDialog::OnButton56() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_KEYDOWN, 56, 1); pView->SendMessage(WM_CHAR,56,1); pView->SendMessage(WM_KEYUP, 56, 1); } void MyDialog::OnButton57() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_KEYDOWN, 57, 1); pView->SendMessage(WM_CHAR,57,1); pView->SendMessage(WM_KEYUP, 57, 1); } void MyDialog::OnButton48() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_KEYDOWN, 48, 1); pView->SendMessage(WM_CHAR,48,1); pView->SendMessage(WM_KEYUP, 48, 1); } where my dialog box is created in the frame and i am getting the pointer of view from CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); but i a creating it in each and every fuction which i don't want to do so i was trying to create in the Dialogs constructor so that too it to the CWnd pointer which is parent for all what do i needto write in the constructor ofthe dialog MyDialog::MyDialog(CWnd* pParent,CWnd* pView) : CDialog(MyDialog::IDD, pParent) { //pView =(CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); } Request to all to continue this
-
abt Alt+keyshello all what code do i need to write in MFC in order to check if the user has clicked alt key on the key board and how can i implement Alt+F4 fuction when the user clickes alt button on the key board and button(with caption F4) which is on my dialog box which is created in an SDI application my alt and F4 button on the dialogbox has the following code in the fuction void MyDialog::OnButtonalt1() { flag=1; if( ( (WM_KEYDOWN||WM_SYSKEYDOWN) && (0x8000 ==(0x8000 & GetKeyState(18)) ) ) ) { MessageBox("in Alt"); } /*if( (WM_KEYDOWN && !GetKeyState(18)) && caps) { Invalidate(); } BYTE keyState[256]; GetKeyboardState((LPBYTE)&keyState); if( (TRUE && !(keyState[115] & 1))||(!FALSE && (keyState[115] & 1)) ) { // Simulate a key press keybd_event( 38,0x45,KEYEVENTF_EXTENDEDKEY|0,0); // Simulate a key release keybd_event(38,0x45,KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP,0); } */ } void MyDialog::OnButtonF4() { int i = GetKeyState(115); if(i) { MessageBox("In F4"); } } Request to all to continue this
-
help in DrawItem()Hi all, I have a dialogbox created in an SDI application on which i placed a ownerdraw buttons and i am displaying some characters on the buttons and when i open the dialog box for the first time with shift key pressed on keyboard i am able to see capital letters on the buttons and when i open the dialog box with out pressing the shift key small letters are apperaring and if I press shift key on the keyboard after opening the dialog box and click on the button i could see the capital letter on the button but my reqirement is when i click shift key on my keyboard after opening the dialog box i shold be able to see capital letters on all the buttons without clicking them my drawitem function is as follow: void MybutCls::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { ::DrawFrameControl(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, DFC_BUTTON, BS_PUSHBUTTON); int iSaveDC; CDC* pDC; pDC=CDC::FromHandle(lpDrawItemStruct->hDC); VERIFY(pDC); short caps=GetKeyState(20); if((0x8000 ==(0x8000 & GetKeyState(16))&& !caps)||(0x8000 !=(0x8000 & GetKeyState(16))&& caps)) { if(lpDrawItemStruct->CtlID==IDC_BUTTON65) ::DrawText(lpDrawItemStruct->hDC,"A",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON66) ::DrawText(lpDrawItemStruct->hDC,"B",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON67) ::DrawText(lpDrawItemStruct->hDC,"C",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); } if((0x8000 ==(0x8000 & GetKeyState(16))&& caps)||(0x8000 !=(0x8000 & GetKeyState(16))&& !caps)) { if(lpDrawItemStruct->CtlID==IDC_BUTTON65) ::DrawText(lpDrawItemStruct->hDC,"a",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON66) ::DrawText(lpDrawItemStruct->hDC,"b",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); if(lpDrawItemStruct->CtlID==IDC_BUTTON67) ::DrawText(lpDrawItemStruct->hDC,"c",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); } iSaveDC=pDC->SaveDC(); pDC->RestoreDC(iSaveDC); // Invalidate(FALSE); }
-
Iabt Floating KeyboardHi all , I have an SDI application in which i have created a dialog box and attached that to frame and on the dialog box I kept few buttons which r owner drawn and all the buttons are members of dialog class and are made as objects of button class,now when ever i click the button on the dialog box keyboard messages should be generated and that character should be sent to the edit view by using the following code they r displaying but giving problem when i keep cursor on them and try to type with keyboard keys void MyDialog::OnButton65() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); BYTE keyState[256]={0}; GetKeyboardState((LPBYTE)&keyState); short shift=0; shift =GetKeyState(16); short caps=GetKeyState(20); if(caps)//shift) { pView->SendMessage(WM_KEYDOWN, 65, 1);///for 'A' pView->SendMessage(WM_CHAR,65,1); pView->SendMessage(WM_KEYUP, 65, 1); } if(!caps) //!Shift) { pView->SendMessage(WM_KEYDOWN, 97, 1);///for 'a' pView->SendMessage(WM_CHAR,97,1); pView->SendMessage(WM_KEYUP, 97, 1); } } the reason is my 2nd and 3rd parameters of SendMessage are not correct can any one tell me how can I send proper wparam and lparam values there so that I can proper out put and which API's gives me those values Request to all to continue this
-
activate the shift and Alt keysHi all How can i change all the key from lower case to upper when ever clicking a button(which is owner draw) on my dialog box which is created in an SDI application, and can u also tell me the functions to be used to get the button status and that which can be passed in my send message such as void MyDialog::OnBUTTONLShift() { } whenever shift button is pressed with mouse all the caps should be shown else all small case charac should be shown on my owerdraw buttons where the code for abutton is written as follow void MyDialog::OnButton90() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_KEYDOWN, 90, 1); pView->SendMessage(WM_CHAR,90,1); pView->SendMessage(WM_KEYUP, 90, 1); } Request to all to continue this
-
about floating keyboardHello , I have a ownerdraw button on a dialog box which is created in an SDI application where buttons are members of dialog class and when evet i click the button i want the keyboard key event to be generated and that caracter should be displayed on the client area what should i do in sent message for this for example if i have A on my button when ever user clicks that button keyboards keyevent should generate and that should be passed and displayed on editview area i have a the function void MyDialog::OnButton49() { /* unsigned char arr[256]; int i= GetKeyboardType(1); GetKeyboardState(arr); GetKeyNameText(49,"a",1); //GetKeyboardLayoutList( GetLastError();*/ // this->GetParent()->SendMessage(WM_PAINT,nRepCnt,nFlags); //SetKeyboardState(; //Get // int i=GetKeyState(49); // if(i==1) GetParent()->SendMessage(WM_CAPTURECHANGED,49,1); //n_butFlag=49; } like this for displaying 'a' on in my dialog class Request to all to continue this