|
I have an ATL COM object that implements two custom interfaces and IDispatch. I can simply CoCreate the object from a C++ console app but when I try to expand the object within the debugger (to see whether IDispatch and IUnknown are inherited correctly), the development environment crashes and Spins up another instance of MSDEV with assembly in it.
Has anyone seen these symptoms before ? Any ideas ?
Thanks
|
|
|
|
|
I want to concatenate two files like Dos prompt.
Example :
COPY File1.txt+File2.txt File3.txt
Thanks in advance
|
|
|
|
|
here it is in plain old C.
FILE *f1 = fopen(file1, "r");
FILE *f2 = fopen(file2, "r");
FILE *f3 = fopen(file3, "w");
unsigned char buf[4096];
int read=0;
read = fread(buf, 1, 4096, f1);
while (read!=0)
{
fwrite(buf, 1, read, f3);
read = fread(buf, 1, 4096, f1);
}
fclose(f1);
read = fread(buf, 1, 4096, f2);
while (read!=0)
{
fwrite(buf, 1, read, f3);
read = fread(buf, 1, 4096, f2);
}
fclose(f2);
fclose(f3);
|
|
|
|
|
Hi
I have problem capturing desktop screen and saving it into a bitmap using DirectDraw. Please help if you've done this before.
Thank you very much for your time.
JD
|
|
|
|
|
We often can see that some function will return a pointer to a structure or a buffer, it must be aollocated by function itself. The question is how the memory is freed? and when it is freed? Can I aollocate some memory in a function and hope the caller will clean up the mass?
I am using C, so the C++ destruction function is not what I want. Thanks
|
|
|
|
|
As long as you tell the programmer calling your function that he/she has to free memory that you are allocating, there's nothing wrong with what you describe.
Also, you should tell the caller which function to use when freeing the memory (free, delete, delete [] , GlobalFree, etc.).
I do it all the time...
-c
|
|
|
|
|
You often see this? You shouldn't. That's very poor programming style.
There are a few cases in the C Runtime library where you see this, but what happens here is that the C runtime library allocates the memory and cleans it up when the program exits.
Generally, memory should be copied, or passed to a function through a pointer or reference, and that memory should be used by the function.
Additionally, COM utilizes a mechanism where the Caller has to clean up memory when using SysAllocString and IMalloc. These rules are clearly documented though. you can't just assume people will clean up your allocations.
|
|
|
|
|
First, I would like to thank both of you for your help.
I am programming a set of netbios support function, one of which need return a structure pointer. and I need call it several times, yesterday i find a way to do this, that is use the 'static' modifier. then there will be only one copy of the structure and it will initialize when the program start and clean up when the program exit. although it will keep it's content through function calls, but that is not a matter.
It's the solution that the C library used?
by the way, I am sorry about my poor english, I am still a student.
mask
|
|
|
|
|
Hi, I can't figure out the cause of the following:
I've derived a general dialog class (say CMyDialogBase) from CDialog and in that class I've put OnOK() with ClassWizard. Then I've derived another dialog classes (say CMyDialogFinal from CMyDialogBase and put in OnOK() as well. Now when I call OnOK() from within CMyDialogFinal::OnOK() I expect CMyDialogBase::OnOK() to be called, but instead CDialog:OnOK() is called, even when I write the call like this CMyDialogBase::OnOK().
With OnCancel I don't get this problem - skipping the base class.
Can anyone tell me what is going on here?
Thx, Joep
|
|
|
|
|
You have inherit two classes from CDialog:
CDialog virtual OnOK()
|
v
CMyDialogBase virtual OnOK()
|
v
CMyDialogFinal virtual OnOK()
and implemented in all classes OnOK().
If you will call always CMyDialogBase::OnOK from class
MyDialogFinal, then delete function MyDialogFinal::OnOK().
The system will always find the virtual-function in
CMyDialogbase and execute this function.
If you use virtual-function, the system checks all class
(start at class from where you call the function) until it finds the function in this class or a higher-class.
I hope that help's.
|
|
|
|
|
Are you certain that you have capitalized OnOK the same in all classes? The fact that CDialog::OnOK is being called when you call CMyDialogBase::OnOK would seem to be a direct indicator that CMyDialogBase::OnOK doesn't exist (or may be spelled or capitalized differently).
|
|
|
|
|
I'm learning about COM in C++.
I want to create a com dll which will have 2 interfaces. 1 public method in each.
I then want to create a client to call a method on interface1, then use QueryInterface to return an interface pointer to interface2, so I can call the method on the second interface.
Both interfaces will have the same method name & parameters.
Where can I get sample code or tutorial to do this?
Cheers.
|
|
|
|
|
Create a new ATL project. Insert an ATL Simple Object from the ATL Wizard and define interface 1. Interface 2 can be implemented through a relatively simple cut and paste operation (although there are a couple of gotchas) - If you have MSDN - this is a good source of explanation. Otherise Inside COM by Microsoft Press, Beginning ATL by Wrox Press
p.s. You can't have the same method name for both interfaces, if you're planning on implementing this within the same C++ class.
|
|
|
|
|
I would like to know if there are any methods to intercept WIN32 API functions? For example, I want to get the string that would be displayed on the screen before it is actually displayed. Any code examples?
Thanks very much and I am looking for examples eagerly.
|
|
|
|
|
Hello eveybody
I didn't understand the values of lpdwFlags in the fonction InternetGetConnectedState
If we know that the possible values are:
#define INTERNET_CONNECTION_MODEM 1
#define INTERNET_CONNECTION_LAN 2
#define INTERNET_CONNECTION_PROXY 4
#define INTERNET_CONNECTION_MODEM_BUSY 8
why I had different results like these:
2: When i use only a LAN
18: When I use a modem (not connected)
81: When I use a modem (connected)
86: When I use LAN and PROXY
What is these values means?
Please I need your help
Thanks for all
Sylvain Demers
demerssy@ift.ulaval.ca
|
|
|
|
|
Hi,
I'm trying to set an enviroment variable from my program, but it vanishes after I make
the call, but it works (at least for the return code)
Is there any trick to make it work ? Or is there another function I need to use ?
Thanks,
Dennis
|
|
|
|
|
I have a dialogue based GUI aaplication,which i need to make a service.How can I do that ? I do not have any main function wherein I can take any commandline arguments.
Xzyeena.
|
|
|
|
|
There should be some helpful information in P.J. Naughter's article here on the site:
http://www.codeproject.com/system/cntservice.asp
|
|
|
|
|
check this:
CCommandLineInfo cmdInfo;
AfxGetApp()->ParseCommandLine(cmdInfo);
if (AfxGetApp()->m_lpCmdLine[0] != '\0')
{
char tmp[1000];
sprintf(tmp,"%s",AfxGetApp()->m_lpCmdLine),
AfxMessageBox(tmp);
}
else;
In CDialog-GUI you need the CWinApp-pointer (AfxGetApp()).
|
|
|
|
|
Hi all,
I have a problem that should have a simple solution. I have an MDI FormView-based app and it has two button on the toolbar where the user can choose to create a new form-based document version 1 or version 2.
Therefore I think I have 2 issues:
one, how to set the global variable after either clicking button 1 or 2. What function should I call after setting the var?
void CMainFrame::OnFileNew2()
{
view = 2; // set the global var
... // what function should be here to continue creating new doc?
}
two, how to choose the view based on the global var.
Can anyone help me? or does anyone have a sample code that just does that?
Thanks a lot in advance.
|
|
|
|
|
peace
every poor app can open an iexplore instance and tell it where to surf to ...
is there a doc on the web about this ?- i ownly found some on how to use CWebBrowser2 to write a new one
thanx
|
|
|
|
|
You can call ShellExecute() and pass it a URL (be sure to include the "http://" part) and it'll launch your default browser.
Look around in the registry under HKCR\http to find out more about the commands issued.
|
|
|
|
|
I am trying to manage a main dialog that must appear at the beginning of the app, disappear when the user has chosen an action an then reappear when the user has finished. It's kind of a primitive approach, but the users are all used to an old DOS program that I am converting to Windows. Can I mange the whole thing in CMainFrame?
Thanks,
F.L.
|
|
|
|
|
yup..make a function that displays your dialog and call that function from OnCreate and then later from OnDestroy... =)
|
|
|
|
|
Hi !
I wanna insert a bitmap in IE menu with the command InsertMenu (SDK) by an other app.
But i've never managed in that task
Someone could help me.
Shellmind.
|
|
|
|