|
Ah! Okay, I'm not sure if I know what you're asking but...
Use m_ctrlListBox.GetHorizontalExtent() to get the scrollable width of the list box, in pixels.
If you just want to know the screensize of the ListBox, use...
CRect rect;<br />
m_ctrlListBox.GetClientRect(&rect);<br />
rect.DeflateRect(CSize(GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)));<br />
iWidth = rect.Width();
|
|
|
|
|
Hi!
Thank you very much! I needed the last one.
Now I have another question and hope you can help me:
I need the lenght of the strings in the ListBox. When I use
m_ctrlListBox.GetTextLenght(0)
I only get the number of variables without the blanks between the words.
Thank you!
Lucky2002
|
|
|
|
|
Call CDC::GetTextExtent() on each string as you add them to your list control, and keep the width of the widest string as the width of your listbox.
int width = 0;
CSize size (0, 0);
CDC *pDC = m_listbox.GetDC();
int saved = pDC->SaveDC();
pDC->SelectObject(GetFont());
while (ThereIsAStringToAdd)
{
m_listbox.AddString(TheStringToAdd);
size = pDC->GetTextExtent(TheStringToAdd);
width = width > size.cx ? width : size.cx;
}
pDC->RestoreDC(saved);
ReleaseDC(pDC);
m_listbox.SetHorizontalExtent(width + 5);
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
Works great!!!!
Thank you very very much ....
|
|
|
|
|
I'm working on a Dialog-based project. The app, as usual, starts my dialog class with DoModal(). However, I sometimes want the dialog to start hidden, depending on calculations done in OnInitDialog(). I know how to use ShowWindow() but where do I control whether the dialog will *start* visible or hidden?
|
|
|
|
|
Mike Dunn's C++ FAQ, §7.6, shows how to have a dialog hidden at start-up. I guess you can adapt the technique to your needs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you. I just tried it and that solution was very easy to adapt successfully. I guess I should have checked the FAQs first.
|
|
|
|
|
Ok this is a simple question.
Can you have all DialogBoxes, TextBoxes, resources etc in DLL, and then have .exe file call some kind of initialisation function contained in DLL that would start whatever application is supposed to do.
Are there any problems with this. I haven't tried implementing myself.
[thinkig in terms of Win32 API]
Regards,
Venet.
--------
Black holes are where God divided by zero.(Steven Wright)
|
|
|
|
|
No problem, but you have to be careful when loading resources, because you need the instance handle; and a simple call to GetModuleHandle(NULL) will not give it to you (it will return the calling exe), so you need to get it in the DllMain function and use for all resource loading tasks.
I can´t see more problems actually...
"nobody knows it, but you´ve got a secret smile, and you use it only for me"
|
|
|
|
|
Thanks
Regards,
Venet.
--------
Black holes are where God divided by zero.(Steven Wright)
|
|
|
|
|
Its dumb question.
I have VS.Net.What/Where is my C compiler file?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
|
Thank you Nish.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I store the name of a user selected database in a member of the document in my MDI project. I need to access the name of the database from the CFileDialog pathname in a function in my mainframe class. If I were in a view class I'd get a pointer to the doc. But if I'm in the mainframe class, how do I get to the string variable stored in the doc?
Thanks,
ns
|
|
|
|
|
|
Okay. Thank you. I'll try it and see if I can accomplish what I want with your solution.
Appreciate your input!
ns
|
|
|
|
|
I can see that everyone has the "SoftWare" key so the first RegOpenKeyEx will always succeed. But the second key "MyCompany" gets created for the very first time when you close the app! SO at startup, when that key isnt even there, I found that RegOpenKeyEx fails, but nothing bad happens and the program continues...
// Open the Software key under HKEY_CURRENT_USER.
RegOpenKeyEx(HKEY_CURRENT_USER, "Software",
0, KEY_ALL_ACCESS, &keyHandle1);
// Open the MyCompany key under Software.
RegOpenKeyEx(keyHandle1, "MyCompany",
0, KEY_ALL_ACCESS, &keyHandle2);
I just wanted to make sure this observation is correct, or whether I need to check for ERROR_SUCCESS etc...
Thank you,
ns
|
|
|
|
|
RegCreateKeyEx opens key if it exists and creates it if it doesn't exist - exectly what you need in such situation.
In any case program should check return code and handle errors. For example, if you run program in Guest account, RegCreateKeyEx may fail.
|
|
|
|
|
I have a CformView containg a list ctrl and other application also is the same.Files are displayed with icons in list ctrls ,i need to drag and drop from one list ctrl to another and vice versa.Plz help me as the deadline for the project is abt to be finished.
|
|
|
|
|
i have an edit control on dialog box and i am not using MFC, i want to validate that only numbers should be entered in the field. what is the possible way out. help me out PLZ
|
|
|
|
|
You're better off doing it yourself anyhow. Handle WM_KEYDOWN in the edit control, and then you can do your own validation. You can set the number style, or if you need negative numbers or decimals, you can deal with that in the same message.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Christian Graus wrote:
Handle WM_KEYDOWN in the edit control
Actually, I think he would be better off handling the EN_UPDATE notification, that way he can properly validate any text that is pasted into the edit control.
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
In the resource editor with the dialog box displayed, right click the edit control, select properties, select the styles tab, then check the Number checkbox. This will allow only the digits 0-9.
|
|
|
|
|
i need to change programatically the tile of the dialog box. Is there anybody having idea which api to use
|
|
|
|
|
SetWindowText
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|