|
If you _really_ wanted to do this, you could try using the /ENTRY:<function> option of the linker (this if for VC++), and set <function> to the mangled name of your static member function. I haven't tried this though, so i'm not sure if it will work.
Anyway, why not just have a one line main function that calls your static member?
Dave
|
|
|
|
|
Dave Bryant wrote:
If you _really_ wanted to do this, you could try using the /ENTRY: option of the linker (this if for VC++), and set to the mangled name of your static member function. I haven't tried this though, so i'm not sure if it will work.
Actually I've already done that and it works, to a point. You just cant call anything, the CRT isn't initialized.
Dave Bryant wrote:
Anyway, why not just have a one line main function that calls your static member?
The reason for doing it is just to do it .
It would be nice to have a totally "OO" application without using C# or Java, in other words, no stand-alone global functions.
Still trying...
-pete
|
|
|
|
|
Anonymous wrote:
It would be nice to have a totally "OO" application without using C# or Java
Try Smalltalk?
It's free, can use DLLs, there even is a version working specifically with .NET, IIRC.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Hello,
I am fairly new to MFC, so please do not beat me up too badly for asking a dumb question.
I am writing an application that consists of a UI and a series of command-line applications to perform compilations on text input through the UI. The general flow of the application is similar to the process that MSVC follows when a project is compiled. I.E. The UI runs a compiler as a separate process and collects output from the process to display on the screen.
I have the "compiler" written (as a command line application) and it works fine. I have the UI executing the "compiler" using the ::CreateProcess() method/function. Input/output from the process is managed using Named Pipes to replace the stdin, stdout, and stderr streams. (I have started a separate thread to monitor and parse the stdout and stderr pipes and send messages back to the application based on the information received.) So far, so good.
I am using a CListCtrl to display the messages to the user, that are received from the "compiler" via the named pipes. However, it appears that the CListCtrl will not actually update the display until the thread with named pipes completes (this is the thread that the CListCtrl display methods are being called from). I have called the Invalidate() method and even sent a WM_PAINT message after each message is added to the CListCtrl. However, it appears that these messages block until named pipes thread completes.
So, my question is:
1. - Can I make the CListCtrl update the display immediately from a seperate worker thread?
2. - Should I be using some control other than a CListCtrl for displaying messages from the separate thread? (The only reason I selected the CListCtrl was to be able to easily store additional infomation with each display message - source code line where the error/warning/message occured and possibly an icon to allow the user to easily distinguish between Errors, Warnings, and Messages.)
Thanks!
|
|
|
|
|
One solution is to send a message to the listbox's parent window and then update it according. That solution is thread safe. Another solution and one that is not thread safe is to pass a pointer of the listbox to the worker thread and allow it to update the listbox in real-time. One disadvantage is the fact that it is not thread-safe. For example, if you call ::WaitForSingleObject() and attempt to update the listbox, a deadlock occurs.
Kuphryn
|
|
|
|
|
SendMessage() is the way to go. Create a custom message, and add a message handler in your UI thread to handle the message. That way you are thread safe, and going about it the proper way.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I have a TCP socket. After connecing to the server I would like to recv data
but recv is blocking. I would like to timeout after 5 seconds if server does not respond. How can I timeout the recv call.
Thanks
|
|
|
|
|
hmm using the asyncsockets usually, but I believe that
<br />
int timeout = SOME_VALUE_IN_MILLISEC;
setsockopt( sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout) );
can help you. Look to the documentation. (valid only for Microsofts Winsock2)
|
|
|
|
|
Use something like WSAselect, or any of the other socket functions that allow you to wait on a socket for data. The benefit is that as well as waiting on the socket, you can also wait for other events in your program
|
|
|
|
|
I can't seem to get any help from the messageboard in the article area. So i try here.
I've seen many people asking on how to get a pointer to a view that is in the controlbar.
But so far i haven't seen any code on how to do it.
I'm not that very good on MFC and i could really need som help with this.
I have added a CFormView to the controlbar, and it works great. But how do i get a pointer
to that view? I need to set some variables, and call some functions but i need a pointer
to be able to that.
Please, could anyone help me?
|
|
|
|
|
Do you know any function to return if the app is running from a server or from the local machine ??
Thanks,
Cris.
|
|
|
|
|
I think you want to use CreateToolhelp32Snapshot(), but you would have to iterate through the snapshot using Process32First() and Process32Next() until you found the exe file you were looking for. This requires windows 95 or later or windows 2000 or later. Check out MSDN for sample code.
|
|
|
|
|
Ok, I meet the exe file. But how can I know if the process is running in the local machine ?? Which variable indicate that ??
Thanks,
Cris.
|
|
|
|
|
If you find the exe in the snapshot collection by calling Process32First()/Process32Next(), then that means your exe is running. If you don't find it, it isn't running. This is from MSDN: A snapshot that includes the process list contains information about each currently executing process.
|
|
|
|
|
Hey Lads,
I basically need to change the URL that somebody tries to navigate to in a CHtmlView derived View from starting with http:// to starting with https:// .
I'm basically going to override OnBeforeNavigate2() and alter the URL there and then pass the altered URL on to be handled as default but I was wondering if there is a different approach to this or if anybody sees a problem with doing it this way???
Regards,
Brian Dela
Run naked in the snow until you're sweating like a stuck pig and can't seem to catch your breath. When the flu becomes pneumonia, they can cure that with a shot. - Roger Wright
|
|
|
|
|
Brian Delahunty wrote:
I'm basically going to override OnBeforeNavigate2() and alter the URL there and then pass the altered URL on to be handled as default but I was wondering if there is a different approach to this or if anybody sees a problem with doing it this way???
Nothing wrong except the fact that translating http to https is odd enough, since it is usually part of the html application logic, i.e. the user should find a *real* link to https.
|
|
|
|
|
.S.Rod. wrote:
http to https is odd enough, since it is usually part of the html application logic, i.e. the user should find a *real* link to https.
I know it sounds strange but it's something that I need to use to access a particular site.
Regards,
Brian Dela
Run naked in the snow until you're sweating like a stuck pig and can't seem to catch your breath. When the flu becomes pneumonia, they can cure that with a shot. - Roger Wright
|
|
|
|
|
CHtmlView now supports a function called OnTranslateURL which you can use to modify a URL before it is loaded. But I think you need .NET (and thus MFC7) to use this function.
|
|
|
|
|
Schlaubi wrote:
CHtmlView now supports a function called OnTranslateURL which you can use to modify a URL before it is loaded. But I think you need .NET (and thus MFC7) to use this function.
Thanks The machines I'll be using it on probably won't have .NET so it's probablyt just stick to my original way.
Regards,
Brian Dela
Run naked in the snow until you're sweating like a stuck pig and can't seem to catch your breath. When the flu becomes pneumonia, they can cure that with a shot. - Roger Wright
|
|
|
|
|
I have a modeless dialog box placed on a modeless dialog box when I am updating some information which takes some time. I call DestroyWindow to end the dialog when the process is done but rarely (don't know why, can't reproduce the results reliably) The dialog turns white ( the overlying one) and no information is entered into the controls unless I click on the window.
This is the code for the dialog:
BOOL CALLBACK WaitDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
SetCapture(hDlg);
SetCursor( (HCURSOR) LoadCursor(NULL, IDC_WAIT));
return TRUE;
case WM_DESTROY:
ReleaseCapture();
SetCursor( (HCURSOR) LoadCursor(NULL, IDC_ARROW));
return TRUE;
}
return FALSE;
}
Does it have something to do with SetCapture and ReleaseCapture. I make sure I call UpdateWindow after I call DestroyWindow but still sometimes it happens. What is the reason for this problem?
|
|
|
|
|
Have you tried yourdlg.RedrawWindow(); ?
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I actually was using UpdateWindow(), but I think I might have found the problem although it's hard to tell since it happens rarely. In your opinion do you think the application got 'stuck' because I called EndDialog for the modal dialog box first (which is the parent window of the WaitDlg (the one that gets 'stuck') and then called DestroyWindow? I noticed this this afternoon and though maybe in some way that if the parent window was destroyed first the second one is left there hanging, like an orphan where most of the times windows takes care of it but sometimes leaves it in the gutter mmm?
|
|
|
|
|
Hi,
I have an ActiveX control, with the source code, I use it in my application ( it uses un ugly wrapper, with calls like raw_(...)).
What I would like to do is to be able of going to the source code of the ActiveX when debugging... is there anyway to do that ?
( or I have to start the DLL in another Visual Studio waiting for a server to activate it ?).
Thanks in advance, greetings
Braulio
|
|
|
|
|
You have to start second instance only if it is outproc and you use VC6.
1. VC6+outproc - wait until Your program instantiates control than attach the second instance of DevStudio to the process of your control(menu Build->Start Debug->Attach To Process).
2. VC7+outproc - wait until Your program instantiates control than attach the studio to the process of your control(menu Debug->Processes).
3. inproc - in both cases it is just normal debugging
|
|
|
|
|
What does a user’s computer have to have in order to use MSChart if I include it in a program? Can I distribute these items with my program?
I have searched MS website but no solid information.
"Best file compression around: DEL *.* = 100% compression."
<><><><><><><><><><><><><>
Matthew R. Miller
mattrmiller@computersmarts.net
www.computersmarts.net
|
|
|
|