|
At the point that you are calling the AddString function, the MFC object for the CComboBox has been constructed, but it's window has not been created. The best place to initialize the combo box is in the OnInitDialog handler for the dialog box. At that point, the dialog and combo box windows have been created but not shown.
Software Zen: delete this;
|
|
|
|
|
|
Hello guys,
I would like to do something easy, or at least that seams to be easy ...
I have an old application based on dialogs.
I would like to modify it to resize its dialog window automatically depending on the screen size and resolution.
Something like :
- at the end of the my OnInitDialog() routine, I test the screen type
- if I am 800*600, I am ok
- if I am more, I resize the dialog window itself to fit the screen size and then I move and resize each of my controls depending on a ratio calculated on real resolution and 800*600.
Seems to be simple, no ?
But how do I do this :
- access the dialog window, resize it
- access each of its controls (lists, buttons, etc), change their position and size.
Thanks in advance
DD
|
|
|
|
|
qadddd_free wrote:
access the dialog window, resize it
Does this mean you're not changing the code in the app ? If you are, then setwindowpos is what you want
qadddd_free wrote:
access each of its controls (lists, buttons, etc), change their position and size.
The best way to do this is to call setwindowpos for all your controls in a handler for the WM_SIZE event, in other words, when your screen resizes itself, the controls also get sized to fit in the window.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello,
Good idea to put all my business in the OnSize() function.
My biggest problem now is to determine the position, length and height of each control depending on the screen resolution.
Thanks for help
Regards
DD
|
|
|
|
|
|
Hello,
It is not really what I was looking for because I would like to keep my code as is, just add the the routine that maximizes the dialog and re-organizes all the controls.
If I would like to do it as described in this article, I would have to change a big part of my code to create all controls independantly, etc ...
But never the less, I will have a look in the part that calculates the new position and size of the control ... )
Thanks
Regards
DD
|
|
|
|
|
Hi DD,
I don't think that you will have to change a big part of your code.
I didn't check it but try this in your OnInitDialog:
#include "anchor.h"
CDlgAnchor dlgAnchor;
CDlgMan dlgMan;
dlgMan.Load(hwndDlg, "Yours project path");
dlgAnchor.Init(hwndDlg);
for(int nIndex = IDC_FIRST_CONTROL ; nIndex < IDC_LAST_CONTROL ; nIndex++)
dlgAnchor.Add(nIndex, ANCHOR_ALL);
then , add the WM_SIZE handler , and add to it :
dlgAnchor.OnSize();
Good luck,
Eli.
|
|
|
|
|
Hi..
i would like to know how to repaint only the selected row rather than repainting the whole listcontrol.
thanks..
sourabh
|
|
|
|
|
RedrawItems
"When you know you're going to eat crow, it's best to eat it while it's still warm." - Reader's Digest
|
|
|
|
|
how to code a checkers software with neural network and genetic algorithm.can anyone pliz help me
|
|
|
|
|
Why didn't you try this[^]?
Software Zen: delete this;
|
|
|
|
|
|
I have an expression including sin,cos,and log. Example 3*sin(4)-2. I want to know how to calculate it. Can you help me?Thanks a lot.
|
|
|
|
|
|
|
I compiled a program in Visual C++ .NET (it is an dialogue based MFC type application). I then did a release build. I copied the release build folder onto another computer (my friends') so he could check it out. When we tried to run it, it said something about a file (I think some DLL) was missing.
My question is, how do I make a release build of my application that can run on people's computers (Windows 2000 and XP) even if they don't have Visual Studio .NET? You can tell I am a newbie at this...but I was wonder how to do that.
Any help you can provide would be greatly appreciated.
Thanks.
|
|
|
|
|
use MFC in static library.
|
|
|
|
|
Just out of curiosity: how many messages can I post to Windows message queue in maximum?My test is 10 thousands messages using user message!any refences?
|
|
|
|
|
I guess it depends on the speed at which the application processes them and the amount of free memory available. If it processes them slowly, then the application might run out of memory, as each message does use up a few bytes.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Fascinating!
That is a question I never thought of asking!
I would assume that it depends on the amount of memory available, like most of our programs.
If you realy want to test the limits, you need to start with 65536 (unsigned int) messages and then try 429496295 (unsigned long) messages. I would suggest that they be user defined messages so you know that they can only be processed by your program. I, personaly, would be interested in the results of such a test; at what point will the stytem up-chuck (crash) or simplily stop exepting new messages (which would be more reasonable, but what message dialogbox would popup).
This is simular to doing a memory test, so test away and have fun!
Keep in mind that it is system dependent (aka. virtual memory available, and operating sytem installed) and not, necessarily, operating system dependent.
P.S. I do know you, but you ask question like a real programmer.
INTP
Every thing is relative...
|
|
|
|
|
John R. Shaw wrote:
you need to start with 65536 (unsigned int) messages and then try 429496295 (unsigned long) messagesWhat do you mean by that?
The following is my test code snippet
#define WM_LIYSH (WM_USER + 100)
BOOL CDlgBasedDlg::OnInitDialog()
{
...
while (nCnt != 1000000)
{
::PostMessage(this->GetSafeHwnd(), WM_LIYSH, NULL, NULL);
nCnt++;
}
}
void CDlgBasedDlg::liysh()
{
static int i = 1;
i++;
TRACE("%d\n",i);
}
It turn out that up to the time I tested the i has various value but all of them are under or equal 10000, and what's more, I got failed Assertion under the
_AFXCMN_INLINE void CToolTipCtrl::RelayEvent(LPMSG lpMsg)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg); }
where m_hWnd is NULL
|
|
|
|
|
LiYS wrote:
What do you mean by that?
I ment for you to test the limits of your system. How you did it was up to you.
The fact that you started seeing assertions, shows that you're memory resourses where all used up. That is the number of messages you can send is based on the avialable memory.
The numbers I gave where just theoretical values for 16-bit and 32-bit processors (depending on the complier used). That is the maximine possible values.
Do you now know what the mximine number of messages that can be sent is?
INTP
Every thing is relative...
|
|
|
|
|
John R. Shaw wrote:
Do you now know what the mximine number of messages that can be sent is?
OK, I know by now it's memory dependent. But It would be more convincing if I know how the assertions related to memory exhaustion.
|
|
|
|
|
Simple: The programmer who wrote the code to create the window, which allocated memory, and failed, just returned a NULL. In other words he did not say why the call failed, he just said it did.
The first serious program I wrote would not tell you what the problem was, as a matter of fact it would not have told you anything 90% of the time. The only guarantee it gave, was that it would not crash your system, or die unexpectatly.
INTP
Every thing is relative...
|
|
|
|