|
hi i want to move button control on mouse LButton down with no Resize and position must be saved within the dialog.
How it can be done.
|
|
|
|
|
First, commas, full-stops and semicolons has a meaning also in natural langage:
Your question can be:
"hi, I want to move A button control on mouse LButton down, with no Resize; position must be saved within the dialog.
How it can be done?"
or
"hi I want to move button controls on mouse LButton down with no Resize and position. Must be saved within the dialog.
How it can be done?"
And they are quite different questions.
Assuming the first, since a control is a window, just use MoveWindow (note: mouse coordinates are obtained in screen coordinates, while move window requires parent client coordinates, so do the proper translation with ScreenToClient ).
I don't understand what you mean with "saved within the dialog": if you mean "saved within the dialog RESOURCE", then give a look to http://msdn.microsoft.com/en-us/library/ms648004(v=VS.85).aspx[^].
Consider also that, unless you are writing a "resource management tool", modifying the resource result in modifying the "exe", and this is not, in general, a good idea: what does it happen if multiple users attempt to to modify your "exe" if it is shared across a network?
It is better to save the control positions in a file stored in a user specific directory (you can get the path with SHGetFolderPath , giving CSIDL_APPDATA as a CSIDL) and, when loading the dialog, change the controls positions (again, with MoveWindow ) accordingly to such file (if existent) before showing the dialog.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
jiya-123 wrote: hi i want to move button control on mouse LButton down with no Resize
Use MoveWindow [^] or SetWindowPos [^].
jiya-123 wrote: position must be saved within the dialog.
To make new position persistent, you may store coordinate values in a configuration file.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Well, what's actually stopping you?
I can see a few steps:
First, you need this to toggle on and off. If it was on all the time, anyone using this dialog will hate you. "I just tried to press OK, but the damn button keeps moving!"
You'll need to subclass your button(s), and override WM_LBUTTONDOWN,WM_MOUSEMOVE,WM_LBUTTONUP. For the button messages, either pass them on as normal, or toggle a "I'm dragging flag". In the mouse button, subtract the current position from the last position, and move the window by that much. Something like:
void CMyMovableButton::OnMouseMove (UINT fFlags, CPoint ptMouse)
{
if (m_bDragging)
{
CWnd *pParent = GetParent ();
MapWindowPoints (pParent, &ptMouse, 1);
CPoint ptDelta = ptMouse - m_ptMouseLast;
MoveWindow (ptDelta.x, ptDelta.y);
SetWindowPos (NULL, ptDelta.x, ptDelta.y, 0,0, SWP_NOSIZE | SWP_NOZORDER);
m_ptMouseLast = ptMouse;
}
else
__super::OnMouseMove (fFlags, ptMouse);
}
You'll also need to store all your window positions when the dialog closes (or store them whenever a control has finished moving) so that you can use that information next time the dialog is used. Maybe make structure full of CPOints (ie, ptOKButton, ptCancelButton) and save that in the registry for use in you CMyMovableDlg::OnInitDialog function?
You might also want to look at CDiagramEditor - DIY vector and dialog editor[^] for an alternate way of doing all this.
It sounds like you have a lot of work ahead of you - and I know no shortcut. I hope you have a strong business case for this, and not just "wouldn't it be cool?"
Maybe when you're done, you could write an article based on it?
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
|
I m having 3 coloumns in my list view
Column1 Column2 Column3
when i click a button Column1 should move to 2nd position column3 should come to first and column2 will be in 3rd position
i m trying this in win 32
thanks in advance
|
|
|
|
|
AFAIK there's no magic for that: you have to rebuild properly the list.
[added]
Wow: it looks like I was wrong...
[/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Have a look at ListView_SetColumnOrderArray . It should do what you're looking for.
|
|
|
|
|
|
Is there any way to remove the space for the title at the top of a groupbox. When I use the GetWindowRect property, it's giving me a rectangle with a gap at the top. I don't want the gap - I want the dimensions of the entire group box, with title area (which I am not using). How do I get this? I found a solution for .NET here, but nothing for MFC:
http://stackoverflow.com/questions/2110148/wpf-groupbox-with-no-header-space[^]
Thanks in advance.
|
|
|
|
|
permutations wrote: When I use the GetWindowRect property, it's giving me a rectangle with a gap at the top. I don't want the gap - I want the dimensions of the entire group box, with title area...
I'm obviously misunderstanding, but what is the difference between the "gap at the top" and the "title area?"
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
No difference - I'm talking about the title area. Is there a way to style the groupbox so no space is given to the title and GetWindowRect will return the entire groupbox, all the way to the top?
|
|
|
|
|
Not that I know of. You might try taking the height of the font and dividing it in half, since that's how much sticks above the group border.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Is there any built-in interface to allow me to make an extension for explorer that sits in explorer's title bar? If not, what is the best way to hook explorer so I can put something in the titlebar?
|
|
|
|
|
|
Problem is, I can't see any way to put something on the title bar of explorer using this.
|
|
|
|
|
Hi,
I upgraded a legacy C++ application from Visual Studio 6.0 to Visual Studio 2008. The application mimics the front panel of a fire alarm system and is implemented by overlaying a bitmap drawing of the fire alarm panel with hidden button controls. When the VS 6.0 version was run with a resolution different than what was originally used to create it, the bitmap and the button controls became misaligned. After upgrading to Visual Studio 2008, this misalignment problem went away(!), so that I could run at any resolution.
A problem that occurred was that when I gave the .EXE to someone else to try on their machine, they received an error dialog that read:
“This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.”
When I looked at the system error log, I saw the following 3 errors had occurred:
1) Source: SideBySide
EventID: 59
Description: Generate Activation Context failed for ...\Panel.exe. Reference error message: The operation completed successfully.
2) Source: SideBySide
EventID: 59
Description: Resolve Partial Assembly failed for Microsoft.VC90.MFC. Reference error message: The reference assembly is not installed on your system.
3) Source: SideBySide
EventID: 32
Description: Dependent Assembly Microsoft.VC90.MFC could not be found and Last Error was The referenced assembly is not installed on your system.
Thanks in advance.
|
|
|
|
|
|
Joe,
Thanks. I didn't mention that I had the user do that because my original question was already long enough. What happened after he did that though was that the application ran, BUT it repeated the behavior that had been seen using VS 6.0 which was that the buttons and the bitmap became misaligned. When I run the app created with VS 2008 on my machine, the buttons and the bitmap stay aligned no matter what screen resolution I use.
I'm going to now have to go back and verify what happens if I run the original executable created with VS 6.0 on my machine.
|
|
|
|
|
Looks like you and your user were using different MFC DLL versions.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
can we change ascii table characters ???
|
|
|
|
|
|
As Chris says, ASCII is a standard coding and you can't change it, we won't let you. However, are you asking if you can change what is actually displayed when you print a particular ASCII character? If that's your question, then the answer is yes. Create your own font. Check out Dingbats for an example of how crazy you can get with that.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
if(0x65)
{
cout << 0x66;
}
??
|
|
|
|
|
Ok, that's possible but trivial. It's obviously not clear to me what he's asking.
The wonderful thing about the Darwin Awards is that everyone wins, especially the members of the audience.
|
|
|
|