|
Well, you'll keep recursing if you send yourself WM_WINDOWPOSCHANGED , as it will trigger OnSize() to be called again, which will send the message again, etc. etc.
What's worked well for me in the past is not bothering with triggering additional WM_MEASUREITEM messages. Instead, move the code from WM_MEASUREITEM into a generic routine (say, CalcItemHeight() ) that will calculate the size of an item. Call this routine from WM_MEASUREITEM , and then also loop in OnSize() , calling CalcItemHeight() and SetItemHeight() (non-MFC: LB_SETITEMHEIGHT ) for each item.
Example:
void CCustomListBox::OnSize(UINT nType, int cx, int cy)
{
SetRedraw(FALSE);
const int nCount = GetCount();
for (int i = 0; i < nCount; i++)
{
int nHeight = CalcItemHeight(i, cx);
SetItemHeight(i, nHeight);
}
SetRedraw(TRUE);
Invalidate(FALSE);
CListBox::OnSize(nType, cx, cy);
}
Shog9
------
Crazy lady with the shiny shoes, where are you?
Kick your feet and calm the space that makes you hollow
Live, Insomnia And The Hole In The Universe
|
|
|
|
|
Hey Shog I haven't really read your answer fully, but I have full confidence in your answer, so again I give you my thanx!!!
I really appreciate this one...not that I didn't appreciate past help, but this makes a huge difference in my control for user friendliness and I just got sooo trying to figure out what was going on...you've saved me countless hours of grief here.
Thanx again!!!
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
if i press ctrl+alt+delete then control should go my own created procedure not to operating system services
r00d0034@yahoo.com
|
|
|
|
|
You cannot do that.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
But you can, just rewrite the GINA.dll, online MSDN has good samples of that, but be aware that u could lock ur system if u did something wrong
Search for gina on msdn!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
how to log off and login user from the system remotely(from server to client)
what is procedure .
r00d0034@yahoo.com
|
|
|
|
|
Have a look at impersonate api calls they allow user to login and logoff user remotely.
Hope that would help
- Nilesh
|
|
|
|
|
I am trying to establish a RAS-connection from a service with
the following code:
//read entry parameters
BOOL password;
RASDIALPARAMS params;
memset(¶ms, 0, sizeof(RASDIALPARAMS));
params.dwSize = sizeof(RASDIALPARAMS);
lstrcpyn(params.szEntryName, name, sizeof(params.szEntryName));
m_error = ::RasGetEntryDialParams(NULL,
¶ms, &password);
LOG(3, "RAS::RasGetEntryDialParams\n"
" name=%s\n"
" phone=%s\n"
" callback=%s\n"
" user=%s\n"
" pass=%s\n"
" domain=%s\n"
" error=%d\n",
params.szEntryName,
params.szPhoneNumber,
params.szCallbackNumber,
params.szUserName,
params.szPassword,
params.szDomain,
m_error);
//try to connect
m_error = ::RasDial(NULL, NULL, ¶ms, 0, NULL, &m_hras);
if (!m_error)
return true; //success
This works just fine if code runs as "normal" executable, but
cannot read dial-up entry parameters from service under
"LocalSystem" account, i.e. LOG prints entry name only.
What security settings am I missing?
Thank you,
Alexey
|
|
|
|
|
how to halt mouse and key board
what is procedure
r00d0034@yahoo.com
|
|
|
|
|
Read up on system hooks, thats prolly a good place to start!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
can u provide the related link about that?
r00d0034@yahoo.com
|
|
|
|
|
|
Hi.
In an MFC project, is better to implement multithreadingusing AfxBeginThread() or a normal create-thread function such as _beginthread() and CreateThread()? I remember Jeff Prosise recommending AfxBeginThread() for MFC. I would like to get more inputs.
Thanks,
Kuphryn
|
|
|
|
|
To paraphrase the docs, any thread that uses MFC must be created by MFC. So if the new thread uses any MFC features (or access MFC objects), you'd better use AfxBeginThread() .
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
|
Hi!
How to detect disk letter change on 2K/XP. Functionality to change drive letters and manage volume mounting points is available from mmc (compmgmt.msc)
Thanks
|
|
|
|
|
how can i get absolute position of my DC on the screen?
|
|
|
|
|
Device contexts don't really have a position on the screen.
They are used to represent a drawable surface-- be it for
a printer, a window, or what-have-you. A window on the screen
is painted from the contents (of a bitmap) to which the dc is
representative. This painting occurs where the window is located
irregardless of anything about the dc. i.e. the position is
a property of the window and not its dc.
To get the position of a window on screen, just use GetWindowRect.
|
|
|
|
|
Depends on what DC you want I guess.
1) CClientDC
2) CWindowDC
Then i'm guessing you could call GetClientRect() and GetWindowRect() and convert the logical points to device points using LPtoDP() which would give you the absolute position of the requested DC in pixels (i think).
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Greetings...
I have a custom drawn window in a dialog box. In the window procedure I am not able to trap WM_LBUTTONDBLCLK, the message is not coming only.
I am getting WM_ONLBUTTONDOWN ?
Any suggestions on how to get WM_LBUTTONDBLCLK.
Thanks in advance.
Ritesh
|
|
|
|
|
That is weird. What does the code in the message queue looks like in your dialog box i.e. ON_COMMAND, etc?
Kuphryn
|
|
|
|
|
Is the CS_DBLCLKS specified in the WNDCLASS.style of your control...?
Just a thought
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Well...CSDBLCLICKS in my wndclass during RegisterWindowEx solved the problem.
Thannks for the suggestion
Ritesh
|
|
|
|
|
Hello,
I am wondering if there is an easy or fast way to resolve DNS names to IP addresses? As of right now I create a CAsyncSocket and connect it to a dns name I then do a GetPeerName to resolve the IP address.. This doesn't seem like a clean way to do this plus i am running this process agains a list of names, this function runs each time I receive a msg from a listening socket, sometimes this takes quite awhile to complete..
Any ideas?
|
|
|
|
|
// Perform the DNS lookup
hostent *pHost = gethostbyname( pszHostname );
if ( pHost != 0 )
{
// Copy the IP address into sockaddr_in structure
// There is only one hostent structure per thread, so we need to copy it before we call the function
// again.
sockaddr_in addr;
memset( &addr, 0, sizeof(addr) );
addr.sin_family = AF_INET;
memcpy( &addr.sin_addr, pHost->h_addr, pHost->h_length );
}
This is unlikely to be much faster though as the DNS lookup itself is the bottleneck
Dave
|
|
|
|