|
Thankx I really appreciate the Lesson is a lot different then procedural programming
Thankx again
|
|
|
|
|
Hey Mark, very nice example. I like this one over the usual Employee / HourlyEmployee / SalaryEmployee examples I grew up with. Guess I just like apples better
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I first learned from an Animal/Cat/Dog-type heirarchy.
I hope it was a good example for the OP...I'm not sure I answered his actual question.
Cheers!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I just noticed I probably didn't answer your question...
ForNow wrote: so to Add members derive that class into your your class
and add the members/data/functions
Yes. To add members to an existing class you can derive your own class from that class and
add the members
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thankx again your notes were better then any C++ course I could have taken
|
|
|
|
|
URLDownloadToFile dont work in worker thread
how do i make URLDownloadToFile work in a worker thread. because this is a blocking function, i got to use a worker thread when i call it. but unforturnately when i tried to use it in a thread it doesnt even work at all. its LRESULT return value becomes like -29581853 or something like that.
also, the file never shows up in c:\abc.txt
here is the code i used
download_result=URLDownloadToFile(NULL, yahoo_url, "C:\\abc.txt", 0, NULL);
how can i make it work in my worker thread?
ref [url]http://msdn2.microsoft.com/en-us/library/ms918866.aspx[/url]
using vc++6.0
winxp
MFC STYLE
|
|
|
|
|
Maybe you need to call CoInitializeEx() on your worker thread.
awah wrote: its LRESULT return value becomes like -29581853 or something like that.
The exact value, preferrably in hexadecimal, would be much more helpful to us than "something
like".
Mark
Microsoft MVP - Visual C++
|
|
|
|
|
I have an data-acquisition application in which data-logging is
performed constantly and data is stored in a CF Card, which acts as the primary data-storage device for the system.
The Windows CE image that i have loaded has support for automatic
detection of USB mass storage devices.
The User can retrive the data from the system (CF Card) thru USB Drive.
There is no screen or console , it is an industrial Controller.
The data acquistion goes on constantly , and the applicaiton
periodically polls the USB slot to see if the user has inserted any
USB Drive in it.
I am using a 4 m long cable for USB Pen drive. This is unavoidable!
The problem caused due to this is that the Pen Drive is sometimes not detected byt he Win CE system. Once the pen drive is not detected, it is never subsequently detected. I want to know which driver is responsible for this, and how I can trap any errors occuring in the USB detection operation. I know tht in case of any errors, the driver disables this device on tht USB port. But it allows the same device on the second USB port , and detectes it too. I observed this during internal testing,,,there is only one port at the client site though.
I think the bus enumeration feature of the USB Host driver disables this device if it cannot detect it in some number of tries.
I was thinking of a solution in which I could clear any error that occurs on the USB port, so that the USB driver wud re-enable the device and detect it.
How can I detect any errors that occur at the Port? How can i clear these errors?
Regards
-CR
|
|
|
|
|
I have a C++ project with multiple .h and .cpp files and with a .cpp file containing the int main() function.
Where do I declare global variables such that they can be accessed by the methods in the various .cpp files?
I declared the variable before the main() function but there is an "undeclared variable" error.
I tried creating a .h file to store the global variable and added the line: #include "globals.h" in the necessary .h files but there were all sorts of link errors.
|
|
|
|
|
Declare in cpp file where it first time used.And for another use use make it extern
|
|
|
|
|
The terms declare and define need to be clarified. A [global] variable should be defined once but may be declared many times. The extern keyword garrantees that a variable is declared but not defined. You could define your global variables somewhere in a source (.cpp) file and then extern (declare) them in a header file (e.g globals.h). So you only need to include that header in any file to access the globals.
--
=====
Arman
|
|
|
|
|
|
Hello,
Is there a way to prevent DLLs being loaded into an application as this is quite a security flaw for DLL injection from other programs.. Is there, for example, a notification which Windows sends to an application window when a DLL is about to be loaded into the application space, which you can then return false to prevent the DLL being loaded?
Thanks for your help!
--PerspX
|
|
|
|
|
Perspx wrote: Is there, for example, a notification which Windows sends to an application window when a DLL is about to be loaded into the application space...
Like DllMain() ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi
I want to exit a running application.I have aquire the handle of running process but i am facing problem in closing this.
GetExitCodeProcess(hProcess,lpExitCode);//problem is here
TerminateProcess(hProcess,(UINT)lpExitCode);
Problem is this when i debug the application
"Unhandled exception at 0x7c81ab1f in DDEmailRecovery.exe: 0xC0000005: Access violation writing location 0x00000000."
|
|
|
|
|
Three things:
1) you didn't show us how lpExitCode declared. If it is smth like so;
DWORD *lpExitCode;
..then surely you will get the error. Declare like so instead;
DWORD dwExitCode;
GetExitCodeProcess(hProcess, &dwExitCode);
2) Had it worked, the wrong code would cry in
TerminateProcess(hProcess,(UINT)lpExitCode);
the 'correct' way would be
TerminateProcess(hProcess,(UINT)*lpExitCode);
Anyway.
3) Why calling GetExitCodeProcess before TerminateProcess??
And in general, TerminateProcess is a non-polite way of making a process exit. Actually the process will not 'exit' but be 'killed'.
-- modified at 10:35 Sunday 1st July, 2007
--
=====
Arman
|
|
|
|
|
In general you should't use TerminateProcess for this purpose (to cause another process to exit). The following is from MSDN:
The TerminateProcess function is used to unconditionally cause a process to exit. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess.
Calling ExitProcess is of no use to you as it kills the calling process.
TerminateProcess is mainly intended to be used by debuggers and system tools as a final solution when everything else has failed. If you want a process to shutdown ask it to. You may want to investigate the WM_CLOSE message and the GenerateConsoleCtrlEvent function (the latter for console applications).
Steve
|
|
|
|
|
call webbrowser.Navigate within a thread via post message to UI thread
i wan to navigate to a website using my webbrowser2 activeX i made. but i need to run threads to execute a webbrowser.Navigate. because webbrowser.Navigate can only be called by the main user interface thread, inorder to use it from within a browser, i would be using the postmessage command to the main thread with a custom message
heres my custom message
<br />
#define WM_GOWEBSITE (WM_APP + 1) <br />
here is the handler for WM_GOWEBSITE
<br />
void Dlg::On_WebsiteVisit() <br />
{<br />
m_webbrowser.Navigate("yahoo.com", NULL, NULL, NULL, NULL);<br />
return;<br />
<br />
}<br />
from within my thread, this is how i posted WM_GOWEBSITE
<br />
th_thread->PostMessage( WM_GOWEBSITE , 0,0);
after running debug , i am very sure the message got posted. But the problem now in the release version is that the page simply does not load.hovering my mouse over the activeX control i get the "half cursor,half hour glass" mouse cursor. the debug version is fine.
does anyone know what is going on?
can anyone please help me? thanks in advance!
|
|
|
|
|
I have MyApplication.exe without DLL file, built with MFC VC++version6. the application is generated by the wizard with no change to default settings. I would like to have the steps(the procedure): how to deploy this application to another computer where Visual C++6 (or visual studio) is not installed. It would be nice to have a simple example.
Thanks
sty
|
|
|
|
|
You just need to ensure that the MFC DLLs corresponding to your Visual C++ version are present in the target computer. For Visual C++ 6, it is MFC42.DLL (for MFC controls) and MSVCRT.DLL (Visual C++ Run-time Library). You could use Dependency Walker[^] to find out what else is your application dependent on.
PS: If you build your application by statically linking the MFC DLLs to it, then you don't necessarily need to have the above said files on the target computer.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
|
how to create manifest file for vista using mfc. pls help me. its urgent
|
|
|
|
|
On Vista you should use the VS2005. In VS2005, go to project properties by clicking "Project | Properties". In the property page go to "Configuration Properties | Linker | Manifest File", select "Generate Manifest" to "Yes". Then n the property page go to "Configuration Properties | Manifest Tool | Input and Output" select "Embed Manifest" to "Yes".
Hope this would help you.
Regards,
Paresh.
|
|
|
|
|
What is the needto use a manifest?
|
|
|
|
|