I have here a simple problem that I could not figure how to do it. I have two buttons, lets say button 1 and 2, I need to swap these button to each others position. This means That button 1 will take button 2 position in the dialog and button 2 will take button 1 position.
For the time being, I changing the text on the button and it looks like its swapping but its just changing the text.
PHP Code:
void CPLAYDlg::OnButton(UINT uID)
{
// TODO: Add your control notification handler code here
SetDlgItemText(uID,"0");
CString str;
str.Format ("%d",uID-1000);
SetDlgItemText(IDC_BUTTON0,str);
}
in the above code, I changed the text of button 0 with the button with uID as ID. Any one can help me on this????
Thank You.
Do you need to do this permanently (i.e. from start-up) or are you saying that you want to the buttons to be swapping positions while the program is actually running?
"A problem well stated is a problem half solved.” - Charles F. Kettering
Originally posted by John E
Do you need to do this permanently (i.e. from start-up) or are you saying that you want to the buttons to be swapping positions while the program is actually running?
Tha buttons is supposed to swap when one of the buttons is clicked. And it should not be permanent as as I may add more buttons and add the same functionality to swap between each other.Is that possible??
Pleasure - incidentally, I've sometimes found that changing a window's style or position - e.g. MoveWindow(), SetWindowPos(), ModifyStyle() etc - can't be relied upon to work immediately in all flavours of Windows. Sometimes the window isn't moved or re-styled until it next gets re-drawn - therefore it's a good idea to force a re-draw by hiding the window and re-showing it again.
"A problem well stated is a problem half solved.” - Charles F. Kettering
You could also use SetDlgCtrlID() and swap the control id's. Combine this with swapping the button text, it might be easier that moving everything around. Plus, this method should preserve the tab ordering or the buttons.
Bookmarks