|
hi
this may be really dumb but here goes...
i have taken bits from norm almonds iocp server stuff and turned it into a console app (my servers need it to be this way apparently) and it seems to work ... not too tough so no applause yet please -
now ... a gui app sits there doing its thing until the user clicks 'exit' ... but a console app goes thru the main() stuff and exits ... geee lauren did you work all that out by yourself?
how do i make it loop forever without using while(1 ==1) or whatever so that it doesnt use 100% processor time?
herb-farming in new mexico? is it my time now?
"... and so i said to him ... if it don't dance and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
You still have access to the synchronization functions like WaitForSingleObject . So if there is some sort of event that you can set to wake up your thread that would be the best solution. The types of objects you can use are:
- Change notification
- Console input
- Event
- Job
- Mutex
- Process
- Semaphore
- Thread
- Waitable timer
You can also set a timeout value so that your thread wakes up automatically if the timeout expires. Just remember to include Windows.h if you want to go this route.
Or you could simply tell your program to sleep, but that still takes up a lot of processing power depending on how long you tell your app to sleep.
Good Luck!
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!
|
|
|
|
|
while (true)
{
SleepEx(1000000, true);
}
(The easy way)
Then it's also alertable
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I would implement this as a service - not a conslole app. This way you could use SCM to stop your service easily.
I vote pro drink
|
|
|
|
|
|
I have a dialog app that I set the font to 14 pt on all the windows.
How do I change the menu font to make it the same or larger than the dialog windows?
Thanks!
|
|
|
|
|
The font of the menu is determined by the system settings, and the actual menu window is as system window, so there is no way to simply set the font of a menu short of changing the systems settings.
Therefore you will have to create an owner drawn menu in order to get the font to appear the way that you want.
Another possible way to do this is to create bitmaps at runtime when your dialog is created that contian the font and the size of the menu that you want, and assign these bitmaps to the menu. That way you only need to do a little bit of setup work when you window is created rather than getting into the messy owner drawn menus. I think this would be the easiest solution, and there is an example in Charles Petzolds Programming Windows book.
Good Luck!
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!
|
|
|
|
|
In MFC there is an easy to get access to CMainFrame and call its methods from anywhere in the application. Just by simply doing this...
CMainFrame pFrame = (CMainFrame*)AfxGetMainWnd();
pFrame->MyFunction(...);
Although in WTL there is method GetTopLevelWindow() that can be used to get access to Top Application Window, but there seems to be no way to cast the return CWindow type to CMainFrame. Take for instance the following...
CMainFrame frm = (CMainFrame)GetTopLevelWindow();
frm.MyFunction(...);
... will not work, as there seems to be no way to cast ATL::CWindow to CMainFrame.
THE QUESTION!!
How would one go about calling CMainFrame method from anywhere in the WTL application (say from distant dialog box)? Without using global variable to store pointer to CMainFrame?
Is there such way? Or am I just dreaming
Thanks in advance
Mike M
|
|
|
|
|
Mike.NET wrote:
Is there such way? Or am I just dreaming
But there are things that you can do to get around this.
When you call this in MFC:
CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
it is returning a pointer to the window that is stored as a member variable inside of the app object.
You could either mimick this behaviour by creating your own app module that derives from CAppModule, and stores this member variable.
Since GetTopLevelWindow only returns a HWND there is no way to cast this handle to a CWindow object without creating a completely new instance of the object. The next best thing that you could do is store a pointer to the CWindow, (or CMainFrame) object in the user data field of the window.
That way you could do this to get the pointer that you are interested in:
HWND hWnd = GetTopLevelWindow();
CMainFrame *mainFrm = dynamic_cast<CMainFrame*>(::GetWindowLong(hWnd, GWL_USERDATA);
if (NULL == mainFrm)
{
}
mainFrm->MyFunction(...);
Good Luck!
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 am trying to find a way to only display the Context Sensitive '?' button in a dialog/property sheet - I don't want the 'X' Cancel button to be displayed.
When I Call this sequence...
ModifyStyleEx(0, WS_EX_CONTEXTHELP); // Add The Context Help '?'
ModifyStyle(WS_SYSMENU, 0); // Remove system menu to get rid of the 'X'
..it first adds the '?' to the menu, and then secondly removes the menu. This results in neither the '?' nor the 'X' being displayed.
This is the only way I know of to remove the 'X' from the menu - is there a way to have it display the '?' but not the 'X', or am I stuck here?
If I am stuck, my second alternative is to find a way to disable the 'X' (grey it out) so that it is not clickable... any ideas on how I go about doing that?
If you have any ideas on one of both of these solutions, please let me know.
|
|
|
|
|
Call GetSystemMenu on your window.
Then you can call DeleteMenu on the close menu item with the SC_CLOSE ID.
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!
|
|
|
|
|
Beautiful - thank you for the backup workaround for my problem!
It greys out the 'X' just fine, allowing the '?' to be displayed.
Hopefully there's a way to hide the 'X' altogether though, I'd much prefer that.
: Dean 'Karnatos' Michaud
|
|
|
|
|
Is there any way to send a string to the control to be displayed? I hate writing to a file first and I don't want to use a string resource.
I have seen where you could send "about:your string" to it but haven't tested that.
Am I missing something?
thanks
Like it or not, I'm right.
|
|
|
|
|
I hope that you are comfortable with COM, because here is what you will need to do:
Get the IWebBrowser2 interface from your HTML control.
Use the get_Document method to get the IHTMLDocument interface.
Call get_documentElement to get the root IHTMLElement interface for the document.
then you can call put_outerHTML to set the HTML string that you are interested in.
Good Luck!
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 need to return a pointer to a structure from a method of an interface.
The problem is that VB can't see the ** pointers, so i think i should use VARIANT.
Do you know how?
rechi
|
|
|
|
|
if VB doesn't have to use the pointer, just use a DWORD - VB can treat it like a Long.
-c
ABSURDITY:
A statement or belief manifestly inconsistent with one's own opinion.
|
|
|
|
|
I start up Visual Studio C++ 6, start adding code, set the compiler for debug mode, 30k lines later, everything works fine. Data is in good shape; class instances initialize properly; member functions call each other as they should.
I then go outside of Visual Studio and execute the exe file from within an Explorer window, and pretty soon I get an unhandled exception error. No chance to debug; program just stops.
So, I go back into Visual Studio, load up the program, perform exactly the same set of user steps ... works just fine.
I know this isn't a problem with debug vs release versions, but why won't it run outside of Visual Studio? What am I missing? Can someone point me in the right direction?
Thanks,
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
What is most likely happening is that your debugger is handling the exception automatically when you are running it in the IDE. There is no debugger to handle the exception if you are not running the IDE.
What you should do is change the Debug | Excpetions settings. On that dialog select all of the exceptions, and change their state to Stop always. That way when the exception occurs in your debugger, it will stop and you will be able to trace the problem.
When you are done you can go back into that dialog and reset the exception handlers back to their default state.
Good Luck!
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!
|
|
|
|
|
Well, this may be a bigger problem, but I don't see where the Debug/Exceptions settings are.
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
Sorry. I found it. The debug menu comes up after the program is started. No wonder I couldn't see it.
Thanks,
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
One other thing to check - file paths. Do you open any files, and do you depend on their existence in certain locations? If you go to Project Settings, Debug tab, is there anything in the "Working Directory" path? Try changing that to point to the directory where the EXE is and see if you get the same crash as when running it from explorer.
I think by default, the "working directory" when running under Visual is the directory where the .dsp is.
If you aren't looking for or opening any files, though, this shouldn't matter.
No generalization is 100% true.
Not even this one.
|
|
|
|
|
Thanks, this is worth checking, but I have already seen other instances where expected files were not present and the file open/error handling routines caught them. I wouldn't think this would give me an abnormal termination error, but if I can narrow down more precisely where the error occurs, I may find that it turns out be something simple like this.
Thanks,
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
I need to make my own file dialog because i want features that are not in the standard one. Does anyone know how to make a control that shows all of the files like the one in the standard file open/save dialog.
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
Have you thought about subclassing the standard file dialog?
You could use the common file dialog, give it your own DialogProc, and add the new controls or features that you are interested in.
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!
|
|
|
|
|
sounds like a good idea, but there is only one problem, i have no idea what so ever about subclassing dialogs. Ill look up on it though, thanks.
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|