|
or you can create the menu manually and call SetMenu() from within the dialogs OnInitDialog() handler.
this is useful if you intend to dynamically modify the top level menu items.
ps. whenever you call SetMenu() , msdn says you must follow up with a call to DrawMenuBar()
|
|
|
|
|
Hi all,
How can i detect mouse over a particular button say (IDC_BUTTON) programatically?
With regards
|
|
|
|
|
Handle WM_MOUSEMOVE .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Use subclass.
Have a look to http://www.codeproject.com/miscctrl/subclassdemo.asp
from our codemate Maunder.
regards.
|
|
|
|
|
I use internet sdk function to write a multi-threads program.
But I find only two or three threads can download http data,other threads is waitting.I want to know what limit the max download threads?The server or the client?
Hi
|
|
|
|
|
To the best of my knowledge, it is the bandwidth of your connection that is limiting the number of threads that are able to download data (actually, all of them are trying, so you can expect all the threads to complete their operations as the first ones stop consuming bandwidth). To prove this point, try using a server in your own LAN (which will provide much more bandwidth) or even within your local machine.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am writting some code to add new buttons in a toolbar at runtime.
My problem:
When i create a new button, the toolbar is not big enough and the last one is no visible anymore. If i move the toolbar to another position in the window (manually, with the mouse), it resize itself automatically and all the buttons become visible again.
How to get the toolbar with the right size automatically , just after adding a new button ?
I try adding Invalidate() and AutoResize(), but it doesn't work.
void CMyAppView::OnAddNewModule()
{
CToolBarCtrl* pToolBarCtrl;
pToolBarCtrl = &(((CMainFrame*)GetParentFrame())->GetToolbar())->GetToolBarCtrl();
TBBUTTON tbButton;
tbButton.iBitmap = pToolBarCtrl->AddBitmap(1, IDB_MY_RUNTIME_ID);
tbButton.idCommand = MY_NEW_COMMAND;
tbButton.fsState = TBSTATE_ENABLED;
tbButton.fsStyle = TBSTYLE_BUTTON;
tbButton.dwData = NULL;
tbButton.iString = NULL;
if (tbButton.iBitmap==-1)
TRACE("I couldn't load the button image");
if (!pToolBarCtrl->InsertButton(1, &tbButton))
TRACE("I couldn't create the new button");
pToolBarCtrl->AutoSize();
} Thanks !
PD: I use ON_COMMAND_RANGE handler, to catch the new event with my predefined ID, thanks Saurwein
|
|
|
|
|
try calling ((CMainFrame*)GetParentFrame())->RecalcLayout();
i'm not sure that it _will_ work but CFrameWnd uses it alot internally when positioning controlbars.
|
|
|
|
|
YESSSSSSSSS!!!!!!!!
great ! it works !
Thanks a lot !
-----
Mit freundlichen Grüssen/Best Regards/Un cordial saludo.
Ing. José Manuel Hostalet Wandosell, Fraunhofer IPA, Abt.323/Robotersysteme
Nobelstrasse 12, D-70569 Stuttgart (Germany)
mailto:jose.hostalet@ipa.fhg.de, http://www.ipa.fhg.de
|
|
|
|
|
If we create a shared memory zone with CreateFileMapping(...) , we have to close it with UnMapViewOfFile(...) and CloseHandle(...) .
My question is this: Is the memory released properly doing just that? Or do I have to take some further action before closing the memory handle?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
From MSDN docs on CreateFileMapping:
To fully close a file-mapping object, an application must unmap all mapped views of the file-mapping object by calling UnmapViewOfFile, and close the file-mapping object handle by calling CloseHandle. The order in which these functions are called does not matter. The call to UnmapViewOfFile is necessary because mapped views of a file-mapping object maintain internal open handles to the object, and a file-mapping object will not close until all open handles to it are closed.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Hi All,
I need to create an application which disables the NT user account programmatically.How do I do this??Do I have to access registry settings from my program to perform this task?? I'm novice in this aspect,so detailed info would be required.
Can anybody help me,
Thanks,
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
Use the OpenService() function of NT.
Use its related functions to manipulate services.
Hope this helps.
Jeremy Pullicino
"Hey man, Taliban, Tali me Banana."
|
|
|
|
|
Hi,
Can you be a bit more specific.I din't get how to use this OpenService() function of NT for disabling a user account.Please explain it in detail
Thanks,
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
abhinarulkar wrote:
Learning is a never ending process of Life
In that case, take some time to learn how to use the function
Look for OpenService documentation in the MSDN - it is not very hard to use.
You are particularly interested in the ChangeServiceConfig.
Hope this helps.
Jeremy Pullicino
Professional C++ Developer
Done any hacking lately?
|
|
|
|
|
HI Abhi,
Use the foll function, its quite simple
NetGroupDelUser
|
|
|
|
|
Somebody PLEASE help me!!!
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q261003&
I found this article but it's incomplete on how to fully implement in my
application. In the example, is "CMyBrowser" an instance of "CHtmlView"?
Because :Exec is not a method of CHtmlView. Can someone
enlighten me on how to implement this code please?
Any assistance would be greatly appreciated.
Best Regards
|
|
|
|
|
Hi
Can anyone please tell me how do I color the Toolbar
Thanks,
San
|
|
|
|
|
How to display the data in mousemove event of mschart?
I need to display the value of series in mousemove event.
I need to draw crosshair in mouse move and if I have 4 series of line graph,I have to display the values at that instance for all the 4 series.
Any help would be appreciated.
Thanks in advance.
Be creative
Once your mind is streched by a new idea, it will never regain its original dimension
|
|
|
|
|
hello,
i Derived a Class from CWnd named CStarter
and in my Application Class i add the code
CStarter *pStarter ;
pStarter = new CStarter ;
bool bRet = pStarter->Create(NULL,NULL,WS_VISIBLE,CRect(0,0,0,0),NULL,10000) ;
and then there is an asertion popups..!!
and then i changed the argument 5 (HandleTo parent window)
to (CWnd*)GetDesktopWindow() ,then there is no assertion,but the return value is 0..
What is the reason,How i can solve it and create a CWnd here...
WUSIWUG
|
|
|
|
|
...to (CWnd*)GetDesktopWindow()...
Use CWnd::GetDesktopWindow() .
rechi
|
|
|
|
|
I've run across a bit of a problem using exceptions and references. Here is
some test code:
class B<br />
{<br />
public:<br />
virtual void fn() { cout << "in B" << endl ; }<br />
} ;<br />
<br />
class D : public B<br />
{<br />
public:<br />
virtual void fn() { cout << "in D" << endl ; }<br />
} ;<br />
<br />
B&<br />
foo( D& d )<br />
{<br />
return d ; <br />
}<br />
<br />
<br />
<br />
void<br />
main( int argc , char* argv[] )<br />
{<br />
try<br />
{<br />
throw foo( D() ) ; <br />
}<br />
catch( D& x )<br />
{<br />
cout << "Caught D: " << typeid(x).name() << endl ; <br />
x.fn() ; <br />
cout << "- b=" << dynamic_cast<B*>(&x) << endl ; <br />
cout << "- d=" << dynamic_cast<D*>(&x) << endl ; <br />
}<br />
catch( B& x )<br />
{<br />
cout << "Caught B: " << typeid(x).name() << endl ; <br />
x.fn() ; <br />
cout << "- b=" << dynamic_cast<B*>(&x) << endl ; <br />
cout << "- d=" << dynamic_cast<D*>(&x) << endl ; <br />
}<br />
}
And the output:
Caught B: class B<br />
in B<br />
- b=0012FF64<br />
- d=00000000
I would have expected that either 1) the D& catch handler would be invoked
since we are throwing an object of type D (even if we are using a B reference)
or 2) the B& catch handler would be invoked but the call to x.fn() would print
"in D"
My reasoning goes like this:
- I create a temporary object of type D and pass it into foo().
- foo() returns that same object via a B reference. But the *actual* type of the
object being returned is still D.
- While I could understand the compiler using the static type of the exception object
being thrown (in this case, B) to figure out which catch handler to use, since
the actual type of the exception object is D, surely D::fn() should be being called,
not B::fn().
GCC is doing the same thing so for once, it appears that MSVC is not in the wrong.
What's going on here and where's my misteak?
|
|
|
|
|
Well, first off you're not using pointers, you're using references. The virtual-ness of fn() is irrelevant because polymorphic calls only happen when dereferencing a pointer.
Second, foo() returns a B& . Since a B& object cannot be implicitly converted to a D& object, the D& catch is not invoked. That would be a downcast, which is not an implicit conversion. It doesn't matter what the "real" type of the object is. The return type of foo() is B& , end of story.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
>>> Well, first off you're not using pointers, you're using references. The virtual-ness of fn() is irrelevant because polymorphic calls only happen when dereferencing a pointer.
Not true. Polymorphism still works even if you're using references. For example:
<br />
D d ; <br />
B& x = d ; <br />
x.fn() ; <br />
prints "in D" i.e. even though we are using a B reference, the program knows that we really have a D object and calls the appropriate virtual function.
>>> Second, foo() returns a B&. Since a B& object cannot be implicitly converted to a D& object, the D& catch is not invoked.
As I said, I could understand if this was the case i.e. the compiler uses the *static* type of the exception to determine which catch handler to invoke. What I don't get is why, given that the actual object being thrown is a D, the virtual function mechanism doesn't seem to be working properly. Or at least, as I would expect
One of the guys at work here suggested that the object was being sliced, but since nothing is ever being *copied*, no slicing could possibly be taking place!
|
|
|
|
|
I wuz wrong! The exception *does* get copied.
From "More Effective C++", item 12:
Regardless of whether the exception is caught by value or by reference (it can't be caught by pointer — that would be a type mismatch), a copy of localWidget will be made, and it is the copy that is passed to the catch clause. This must be the case, because localWidget will go out of scope once control leaves passAndThrowWidget, and when localWidget goes out of scope, its destructor will be called. If localWidget itself were passed to a catch clause, the clause would receive a destructed Widget, an ex-Widget, a former Widget, the carcass of what once was but is no longer a Widget. That would not be useful, and that's why C++ specifies that an object thrown as an exception is always copied
So, since at the moment the object is being thrown, we have a B&, a B object is what we get. Sigh...
|
|
|
|