|
Maybe this will help:
1. Add "Notify" style to your button of interest.
2. In Function "WindowProc" of your dialog (the parent of the button of above), add the following coding:
int ControlID;
int NotificationMessage;
if ( message == WM_COMMAND )
{
ControlID = LOWORD(wParam);
NotificationMessage = HIWORD(wParam);
if ( ControlID == IDC_BUTTON1
&& NotificationMessage == BN_CLICKED )
m_buttonPressed = 1;
// you may use this variable in your OnAnyButtonClick(),
// it indicates which button is pressed.
}
return CDialog::WindowProc(message, wParam, lParam);
|
|
|
|
|
I have several icons defined in resource part of my exe file. When the system paints the icon in the directory folder or elsewhere, it is obviously one of those it has found in the exe's resources.
Now the question.
How the system decides what icon to display, if I have many of them. I think it displays the first one found in the resource section of exe, but I am not sure. If this is true, how can I determine what icon should be the first. I noticed, that Visual C++ resource editor sorts the icon identifiers alphabetically to make the order (it does so for every type of resource). That order is also kept in the exe file, I think, but I have no control over this process. Except perhaps of stupid making identifier names to keep certain order. Could anyone clarify this for me?
|
|
|
|
|
golem wrote:
Visual C++ resource editor sorts the icon identifiers alphabetically to make the order (it does so for every type of resource). That order is also kept in the exe file
It does not even depend on the alphabetical order of identifiers as I thought. I had to change ID values in resource.h manually. The smallest value of icon ID made the icon to be main of the program.
But I don't like this approach and everyone knows that manual rewritting of resource.h is debatable.
|
|
|
|
|
golem wrote:
But I don't like this approach and everyone knows that manual rewritting of resource.h is debatable.
I manually renumber my resource.h all the time, why don't you like doing this?
Michael
|
|
|
|
|
Petzold book says that it is unwise. Am I to second him or you?
|
|
|
|
|
Hi there...
I have a dialog based application, which is always on top (HWND_TOPMOST). I have fixed the position of the dialog box to the bottom portion of the screen.
# Now, as soon as the dialog is displayed, I would like to resize the height of all the other already running applications windows, with in the space above my dialog window. Can u tell me how to do this? How do I get the other window handles?
# Also, is there a way to control the positioning of applications that could be spawned in the future? What I want is to reserve one fourth portion of the screen, when my application is running, as I dont want portions of other apps to go beneath my dialog(which is always on top).
Thankx in advance.
-Dave
|
|
|
|
|
I think you'd be better off, making your dialog an app-bar. Similar to the office short cut bar
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
..and how do I do that? Any material in this forum which can put some light on the how-to-do part of it?
Also, if decide to make it a app-bar, will it have all the properties that I desire?
Thankx again Nish..
-Dave.
|
|
|
|
|
Look up this function :- SHAppBarMessage
Regards
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I wanna to do that: click a button ,then cursor changed (for example a hand cursor) ,until click somewhere again,the cursor change to normal. I do that in my application'w windows. But the cursor change to normal as soon as it move out the application's window,Why? and what can I do ?
this is my code responsed WM_SETCURSOR
BOOL CTestDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if(!m_bArrow)
{
//IDC_CURSOR1 is my cursor resource
::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
return TRUE;
}
else
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
thank you!
|
|
|
|
|
The dialog window's class cursor must be null too.
Nish
p.s. MSDN Snip follows :-
The cursor is set only if the new cursor is different from the previous cursor; otherwise, the function returns immediately.
The cursor is a shared resource. A window should set the cursor shape only when the cursor is in its client area or when the window is capturing mouse input. In systems without a mouse, the window should restore the previous cursor before the cursor leaves the client area or before it relinquishes control to another window.
If your application must set the cursor while it is in a window, make sure the class cursor for the specified window's class is set to NULL. If the class cursor is not NULL, the system restores the class cursor each time the mouse is moved.
The cursor is not shown on the screen if the internal cursor display count is less than zero. This occurs if the application uses the ShowCursor function to hide the cursor more times than to show the cursor.
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
This is my 2nd reply to your post. I think I might have mis-interpreted your question. If you want to change the windows cursor then you might want to look up :-
SetSystemCursor
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I have MS VC++ 6.0 on Pentium 4 @1500MHz.
Scrolling the screen or typing is incredible slow! Every other program works ok,
cpu shows 0-4% load while moving up ONE line can take 2-3 seconds.
The project I have open is not big and I have used it on laptop without any
problems.
Could slowliness be caused by having the project files on a server?
(The server is fast, usually I have no problems with it)
I need to upgrade to AMD? *grin*
|
|
|
|
|
I have no idea why, but moving the files from the network
drive to my hard disk removed the "lag".
|
|
|
|
|
long h3
double h2;
float h4;
h4=4.35*100*150/100.0; //float
h3=(long)(h4+0.5); //=653 !
h2=4.35*100*150/100.0; //double
h3=(long)(h2+0.5);//=652 !
What is wrong in the source sample ? Bug casting ? Illegal casting ?
Tanks for your answers.
|
|
|
|
|
What version of VC++ are you using? Is this all the relevant code? On VC++ 5.0 your code compiles fine (after adding a missing ';' after long h3 ) and I only get a warning message in the assignment to h4 :
warning C4305: '=' : truncation from 'const double' to 'float'
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry for the missing ";"...
I know the warning... but I'm very surprised it works in VC 5... I use VC6... I'm going to install my old VC 5 to see if I have the right result.
Thanks.
Seb.
|
|
|
|
|
Are we talking about the same thing ? I have no problem to compile this code. What I am searching is why the result is different between the 2 lines (652 != 653)...
|
|
|
|
|
Oh, I completely misunderstood your first point. Sorry.
There's nothing wrong with your code. The strange behavior is due to rounding errors inherent to floating point arithmetic. These numbers are stored in a internal format like this:
s*mantissa*2^exponent
Where s is the sign (+1 or -1) and mantissa is a number between 1 and 2, with a fixed number of decimals. Due to the limited amount of decimals (binary decimals, to be exact) in mantissa, some numbers that in base 10 have a finite number of decimals can only be approximated by a float or a double . Also, these two types reserve differents amounts of memory for representation: float s are 4 bytes wide and double s take 8 bytes, so these latter are more precise although this is not always the case --keep on reading.
In your specific case, I've taken a look at the internal representation of h4 and h2 and the exact values are:
h4 = 10690560 * 2^-14 = 652.5
h2 = 5739450696990719 * 2^-43 ~ 652.49999999999988631316227838...
and from this is obvious to deduce why you obtain different results when adding 0.5 and truncating to long .
If you want to know more about floating point arithmetic, do a search on Internet for "IEEE 754" (the standard most microprocessors are based upon for this kind of things).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have installed a VC 5 : same problem (652 vs 653)
Can you test this :
h4=2.67*100*150/100.0; //float
h3=(long)(h4+0.5); //= 401 ???
h2=2.67*100*150/100.0; //double
h3=(long)(h2+0.5);//= 401 ???
I suspect an error on some type of configuration...
Thank your for your answer...
Seb.
|
|
|
|
|
The double h2=0.5+ (4.35*100*150/100.0); isn't actually 653 but looks like it is
652.9999999999999 , hence the cast truncate returns 652.
printf and the IDE debugger don't show this.
we can see by adding this code
if ((653.0-h2)==0) printf ("equal\n");
also by adding .0000000000001 to h2 before the cast, it then becomes 653 as expected.
The float value must be truncating somewhere and avoiding the rounding error. . (guessing)
|
|
|
|
|
Question: Does this SDK work with MFC?
If so are there any documents? Seems MS make their docs a lil hard to understands hence my lack of success with MSDN
Thanks
Ashman
|
|
|
|
|
The SDK is based around COM interfaces, so yes it will work with MFC/C++/ATL etc?
The only documentation I've seen so far is on the November 2001 platform SDK. I had a quick glance and found it to be a little confusing also. I have an idea for using the SDK but I'm going to have to do some reading first.
Michael
|
|
|
|
|
Hello everybody!
Who may help me with such question
The size pInfo->m_rectDraw always is less than structure CPrintInfo , than the real size of a sheet.
Whether it is possible to determine displacement m_rectDraw from the left top corner of a sheet, if yes, as?
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
Can I build a CDialogBAR from an in memory resource, a dlgtemplate?
I prefer memorybased Dialogs then .rc-based one for several reasons and I wanna do so with DialogBars, too. Is it possible?
What do you think about dlgtemplATE-Dialogs at all, any pros or contras?
mfg HintiFlo
|
|
|
|