|
Well this code is written using win32++ as I don't have access to a mfc enabled copy of VS, but I'd (foolishly?) assume that it would work just the same in either case.
The code I posted will decrease the size(height) of the window, while increasing the size(height) of the non-client area.
The header will respond in just the same way as the non-client area for a tree control normally will. The window proc for this control only handles WM_NCCALCSIZE and WM_NCPAINT messages, passing any others to the original wind proc.
Here's what the wind proc for the class looks like in it's entirety:
LRESULT CLeftView::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_NCCALCSIZE:
return OnNcCalcSize(wParam, lParam);
case WM_NCPAINT:
return OnNcPaint(wParam, lParam);
}
return WndProcDefault(hWnd, uMsg, wParam, lParam);
}
I'm afraid I have no recollection of where I picked this trick up, though it seems to work just fine. If I've left things unexplained, or you like the class source, I'd be happy to expand on what I've said, or mail you a copy of the class.
Simon.
[EDIT: Oops, looks like I misread that first post. Sorry 'bout that Jim. I've not used the functions you mention before, I'll see if I cant come up with something that achieves this affect using them.]
modified on Monday, April 14, 2008 12:25 PM
|
|
|
|
|
Hi,
I want to find all title of windows. But the code is giving 2 errors:
code is:
<br />
void CMainFrame::TrackWindow()<br />
{<br />
HWND hwnd;<br />
LPARAM lParam = 0; <br />
<br />
while(EnumWindows((WNDENUMPROC)EnumWindowsProc,lParam))<br />
{<br />
EnumWindowsProc(hwnd,lParam);<br />
}<br />
}<br />
<br />
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)<br />
{<br />
char text[200];<br />
GetWindowText(hwnd,text,200);<br />
AfxMessageBox(text);<br />
return TRUE;<br />
};<br />
<br />
Erros are:
1.'type cast' : cannot convert from 'overloaded-function' to 'WNDENUMPROC'
2. unable to recover from previous error(s); stopping compilation
|
|
|
|
|
1) Do you have a prototype for your callback function before the call to EnumWindows ?
2) <pet peeve> Change the name of the callback function to something other than the default. </pet peeve>
Judy
|
|
|
|
|
Thank you, Its working but I want to know the WindowPlacement using GetWindowPlacement() . The below code is returning null in WINDOWPLACEMENT variable.
<br />
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)<br />
{<br />
char text[200];<br />
GetWindowText(hwnd,text,200);<br />
CString szWindowTitle=text;<br />
WINDOWPLACEMENT *WndPlacement=NULL;<br />
if(szWindowTitle=="My Window")<br />
{<br />
GetWindowPlacement(hwnd,WndPlacement);
szWindowTitle.Format("%d",WndPlacement->showCmd);<br />
AfxMessageBox(szWindowTitle);<br />
}<br />
<br />
return TRUE;<br />
};<br />
|
|
|
|
|
pther wrote: The below code is returning null in WINDOWPLACEMENT variable.
Well, of course it is since you initialize WndPlacement to NULL. You're not using the function correctly. You need to supply the buffer to receive the requesetd information. Try this.
WINDOWPLACEMENT WndPlacement;
if(szWindowTitle=="My Window")
{
GetWindowPlacement(hwnd,&WndPlacement);
szWindowTitle.Format("%d",WndPlacement.showCmd);
AfxMessageBox(szWindowTitle);
}
Judy
|
|
|
|
|
pther wrote: while(EnumWindows((WNDENUMPROC)EnumWindowsProc,lParam))
Why the cast?
pther wrote: EnumWindowsProc(hwnd,lParam);
Why are you calling this function directly? EnumWindows() will do that for you, hence the callback.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I'm tring to set the Font and Fontsize to "MS Sans Serif" and 14, the code below does not seem to do it...what am I doing wrong? Is there an easier way to do this?
Thanks
CFont LargeFont;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = 24;
lf.lfWeight = 400;
strcpy(lf.lfFaceName, "MS Sans Serif");
GetDlgItem(IDC_STATIC5)->SetFont(&LargeFont);
|
|
|
|
|
You never initialize LargeFont.
Why don't you use CFont::CreatePointFont ?
|
|
|
|
|
As addendum to Cédric reply, please note you probably have to use
lf.lfHeight = -MulDiv(24, GetDeviceCaps(hDC, LOGPIXELSY), 72);
to obtain a 24 point sized font.
See [^].
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
|
|
|
|
|
C++NewBe wrote: CFont LargeFont;
Where is this object declared?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
The original Post was missing this:
VERIFY(LargeFont.CreateFontIndirect(&lf));
|
|
|
|
|
Ok, but that did not answer my question.
Is your problem solved now?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This is my code....what am I missing? I thing it's the height and weight that is giving me problem. I am from VB world.
thanks
CFont LargeFont;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = 24;
lf.lfWeight = 400;
strcpy(lf.lfFaceName, "MS Sans Serif");
VERIFY(LargeFont.CreateFontIndirect(&lf));
GetDlgItem(IDC_STATIC5)->SetFont(&LargeFont);
|
|
|
|
|
C++NewBe wrote: CFont LargeFont;
Where is this object declared? If it is not global, or is not a member of the dialog, it will go out of scope before SetFont() has a chance to work.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Now I understand....it is being declared on ::Paint()
|
|
|
|
|
C++NewBe wrote: it is being declared on ::Paint()
Therein lies the problem.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello all,
I need checkboxes in List box.I am using Visual Studio 2003.
please suggest some solution.
Thanks & Regards,
Rahul
|
|
|
|
|
Link[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
Rajkumar R wrote: multi-check ListBox[^] may be useful,
Had you followed my link, that's the same article I suggested too, besides indirectly telling him to use Google too.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
Hi,using native C++ in dlls called from a VB.NET application I want to dynamically allocate up to 3 GB of memory, in stages, using the “new” command.
The following code (example to illustrate the problem) produces the following error “Unhandled exception at 0x7c81eb33 n VMTest.exe: Microsoft C++ exception:std::bad_alloc at memory location 0x0012fe10..”
I have configured the virtual memory under control panel|system properties|Advanced tab|Advanced tab|settings to “System managed size” and customised with Initial size = 756 and Maximum size = 8192 with no success. I am using VS2005 on XP SP2.
Please can anybody advise me on a way forward using the "new" command or an alternative.
#include "stdafx.h"
#include <iostream>;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int count = 1000000000;
char buf;
char * cmemblock;
char unsigned * cumemblock;
cout << "Start of program" << endl;
cmemblock = new char [count];
cout << "cmemblock created" << endl;
cin >> buf;
cumemblock = new char unsigned [count];
cout << "cumemblock created" << endl;
cout << "Memory taken" << endl;
delete[] cmemblock;
cout << "cmemblock deleted" << endl;
delete[] cumemblock;
cout << "cmemblock deleted" << endl;
cout << "Successfull completion of program" << endl;
cin >> buf;
return 0;
}
|
|
|
|
|
Member 3363498 wrote: I want to dynamically allocate up to 3 GB of memory,
Why do you want to ever do such a thing ?
|
|
|
|
|
Hi Cedric, system requirements change. The application I am working now has to process large amounts of raw (binary) data. I was under the impression that Windows XP virual memory management would take care of data larger than RAM size. I could change the program so that I read chuncks i.e 0.5 GB at a time but this will impact other parts of the system.
My current development PC has 1GB of memory so I have will be upgrading as soon as possible.
Cheers,
Aubs
|
|
|
|
|
Member 3363498 wrote: Windows XP virual memory management would take care of data larger than RAM size
It will but if you're gong to be manipulating those huge chunks of memory at once - as in repeatedly allocating 4 GB then running through the entire 4G allocation - you're system is going to be constantly thrashing on the paging file. The additional time spent accessing the hard drive is probably going to be greater than whatever time you will gain be rewriting your logic to use the bigger chunks of memory. Processor speeds blow away disk access speeds.
Also, even if you put more than 4G of physical memory in your machine, XP cannot access it. It has a hard upper limit of 43G (32G using the default settings).
Judy
modified on Tuesday, April 15, 2008 8:38 AM
|
|
|
|