|
I think that looking through MSDN is a skill that you become good at only after years of practice and experience.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
The good thing though is that it will take years to complete your first search, so by the second one you'd be an expert...
Isaac Sasson,
Lean, mean posting machine!
Sonork ID 100.13704
|
|
|
|
|
SetCursorPos(x, y) where x and y are screen coordinates.
If you have client coordinates or coordinates relatives to another window, then you can uses function like MapWindowPoints or ClientToScreen to do the proper conversion.
Philippe Mori
|
|
|
|
|
Hi, could anyone give me an answer to this.
We have a long operation involving that we have wrapped with a CWaitCursor. However, during the processing, the cursor flickers back and forward to the pointer.
Any ideas what we can do to keep the hourglass visible?
Cheers,
Steve.
if(E_NOINTERFACE == pThat->QueryInterface(IID_IUnknown,(void**)&pUnk))
{
// I aint no pUnk bitch!
}
|
|
|
|
|
Whenever you window need redraw, the cursor is updated. If you want to stick to your CWaitCursor, you need to overwrite SetCursor().
|
|
|
|
|
Ahhhh,
documentation.
Maybe I should have read it in the first place.
Thanx for your help.
Steve.
if(E_NOINTERFACE == pThat->QueryInterface(IID_IUnknown,(void**)&pUnk))
{
// I aint no pUnk bitch!
}
|
|
|
|
|
I think it's simpler to just do:
AfxGetApp()->DoWaitCursor(1);
doSomething();
AfxGetApp()->DoWaitCursor(-1); /ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
If fact, temporary cursor are restored as soon as the mouse is moved (see SetCursor doc) and in pratice, it means that the cursor will be restored if windows messages are processed which may be the case if something with a message loop is called (COM apartment switching, message box,...).
The only way to ensure that the wait cursor stay displayed is by calling something that will do a permanent change of the cursor (or also by processing WM_SETCURSOR) or by associating a NULL cursor with your window.
In MSDN documentation, it is said that the cursor must be restored if an operation cause the cursor to be changed (see CWaitCursor::Restore).
Philippe Mori
|
|
|
|
|
Hi guys n gals, how do i disable a push button at runtime?? Is there a function in CButton class to disable a button? I couldnt find one.
thx
bye
|
|
|
|
|
Use EnableWindow(FALSE) for the buttons you want to disable.
for example, you have a push button with a control member variable m_ctlButton associated with it. So
m_ctlButton.EnableWindow(FALSE);
|
|
|
|
|
All CWnd derived class's have the EnableWindow(true/false) function
Also take a look at the CWnd class member functions to see what may also be applicable to your button or other window types.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Question: What is the maximum # of variables you like to pass into a function before you decide it needs redesigning to use a struct or some other method?
I have an old math library, some functions take 10 parameters.
Just curious if there was any "common-sense" standard.
(I have no common-sense, so I have to ask....)
- Codin' Carlos
|
|
|
|
|
The number that I have grown accustomed to is 7. But that is more because I used to program for Sun machines, and that is the number of variables that would be placed in registers before they were passed on the stack.
This is not really an issue with the VC++ compiler because it always passes the paraemters on the stack. Therefore a sensible number between 4 and 7 is good, but it will not hurt you to have a number of parameters like 10. It just becomes more cumbersome.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I did a little more research and found that if you only use between 1-3 input parameters, depending on what you do inside of your function, then compiler is able to use the registers as input parameters. x86 does not have that many free registers, so if you use them up on input parameters, there will be no registers to perform operations with.
Hope this extra information will make a difference.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
kilowatt wrote:
x86 does not have that many free registers
Actually, it doesn't have that many registers at all, free or not.
But you seem to be right in your assessment of how MSVC handles the case, only that I've never seen it reduce it to one single fre GPR. Two, possibly, but never one. Also worth to keep in mind is that MSVC hardwires ECX to the 'this' pointer for member functions, reducing the number of free GPR's to 3 (only two more than it's Z80 relative - no wonder since they both are created at about the same time :-> ).
|
|
|
|
|
IMHO, if this struct isn't getting passed around multiple times between the main subroutine and internal subroutines, there is little point in using structures.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Right-o ol' bean.
In this case, the main routine will be calling the same few routines every time the user updates a numerical edit box or two.
So putting into struct would be 'faster' and more efficient;
Putting as individual parameters is more 'programmer friendly' and self documenting (only need function declaration, not function and structure declaration)???
hmmmmm....
- Codin' Carlos
|
|
|
|
|
It might also be more efficient to pass the struct by reference.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
putting it in a struct might be faster for the actual call, since you only have to pass the address of the struct (if you're passing by reference). but you still have to put the stuff in the struct, which will probably take just as long as putting the stuff on the stack.
i only put things in structs when the parameter list itself gets too long for easy reading (somewhere around 8 or 10 items).
-c
<font size=-2>
o(int O){putchar(O);}main(){float l[8],O,I=.05;char _;for(l[6]=15;l[6]<':';o
(10),l[5]=-'$'*I+l[6]++*I)for(l[7]=-5;l[7]<'@';l[4]=-'('*I+l[7]++*I,o(_?'?':':'))for
(*l=O=0,_=1;++_&&((l[2]=*l**l)+(l[3]=O*O)<4);O=*l*O+l[5]+O**l,*l=l[2]-l[3]+l[4]);}</font>
|
|
|
|
|
In fact, for readability a structure will be preferable particulary if there are no hint about what each parameters are:
f(true, false, true, true, true);
Looking at this code it's hard to know what the third parameter means (and it is easy to swap parameters by errors).
As mentionned in another answer, 7 parameters are generally what is considered as a maximum for readability...
Structures or classes also allows to set parameters to default values. If everything is inline and a good compiler is used, the compiler should be able to remove useless initialisation.
Structures or classes (I prefer classes with private members), also allows to easily add a parameter, have default options or compute parameters.
Also if most parameters are optional and different subset are used depending on the context, different constructors can be provided.
Finally as someone else said, if the function is called only from a few places it will be simpler (faster) to pass all those parameters than to define a structure (or a class). But if the code is often used, a better design is in order. The best solution is to make a class with all the data private and inline accessor as this will greatly simplify maintenance if you need additional parameters (or you want to remove obsolete parameters).
Philippe Mori
|
|
|
|
|
I'm trying to take a user input string and then use it like an already declared var. Any idea on how I can do this?
Ex. Users enters myvarX then I use this string to access the variable myvarX.
Thanks for any help.
Jim
|
|
|
|
|
As far as I know this is not possible in C
but you can still declare a std::map<string, some_type="">
and use it, but I think it's not you wanted
|
|
|
|
|
Use a scripting language like Tcl. (You can embed a Tcl interpreter in your Windows app).
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I've never programmed in Tcl, could you give me an idea of how this would be done?
Thanks
|
|
|
|
|
I am looking for some code to draw a minimize to tray button on the caption bar of my window. If any one could help that would be great.
Kurt
|
|
|
|