|
i'm able to add methods to an Interface that returns integer value, like i declared
[Add method]
method name : MathAdd
parameters : int x,int y,[out,retval]*int sum;
[/Add method]
and the implementaion,
[implementation]
STDMETHODIMP StATL::MathAdd(int x, int y, int *sum)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*sum = x + y;
return S_OK;
}
[/implementation]
and i'm using this in a VB application thru referncing.
Now, how do i make a method thats gonna return a char value,
i tried like ,
[Add Method]
Method Name : ReturnString
Parameters : char * inpString,[out,retval]char *outString
[Add Method]
[implementation]
STDMETHODIMP StATL::ReturnString(char *inpString, char *outString)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
strcpy(outString,inString);
return S_OK;
}
[/implementaion]
but i get the following errors,
[stinker]
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1827) : error C2259: 'CComObject' : cannot instantiate abstract class due to following members:
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator >::CreateInstance(void *,const struct _GUID &,void
** )'
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1827) : warning C4259: 'long __stdcall IStATL::ReturnString(unsigned char *,unsigned char *)' : pure virtual function was not defined
d:\proj\stratl\stratl.h(80) : see declaration of 'ReturnString'
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator >::CreateInstance(void *,const struct _GUID &,void
** )'
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1827) : error C2259: 'CComObject' : cannot instantiate abstract class due to following members:
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator >::CreateInstance(void *,const struct _GUID &,void
** )'
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1827) : warning C4259: 'long __stdcall IStATL::ReturnString(unsigned char *,unsigned char *)' : pure virtual function was not defined
d:\proj\stratl\stratl.h(80) : see declaration of 'ReturnString'
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator >::CreateInstance(void *,const struct _GUID &,void
** )'
[/stinker] ..
how to go
plz note : this is my first attempt in ATL ,i was fooled when i searched for a "Hello World ATL"
thanks in advance
V
|
|
|
|
|
char is by default "signed" in VC, and "unsigned" in MIDL.
(giveaway: the compiler misses a function 'long __stdcall IStATL::ReturnString(unsigned char *,unsigned char *)' )
However, to pass strings across a COM interface, your MIDL declaration is not sufficient. (The bad thing is that in most cases it will go well, but can fail in another scenario quickly).
zero-terminated strings (those used in C) are not natively supported in COM. Though you can coax MIDL into using them, many clients will have problems with this.
The normal way to pass strings through a COM interface are BSTR strings. They are unicode strings, and must be handled using SysAllocString and it's companion functions.
Here are the basic rules of working with BSTR's:
- You must not free your [in] BSTR. the pointer is valid only during the function call (if you need to store the pointer, you need to copy it)
- You must "allocate and forget" the [out] BSTR
- NULL is a valid BSTR and must be treated like an empty string
VC offers a support class, _bstr_t that makes handling BSTR's (mostly) easier.
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Is there a C function to assign a file association in windows? I would like to pass as arguments a file extension and a path of the application which it would be associated with. ( open with ).
Just livin a dream.. dont wake me!
|
|
|
|
|
If you are using MFC, check out CWinApp::EnableShellOpen() and CWinApp::RegisterShellFileTypes() .
If not, you'll need to add some stuff to the registry manually. A basic .reg file looks like:
REGEDIT
HKEY_CLASSES_ROOT\.dbc = David.Document
HKEY_CLASSES_ROOT\David.Document\shell\open\command = DAVID.EXE %1
HKEY_CLASSES_ROOT\David.Document\shell\open\ddeexec = [open("%1")]
HKEY_CLASSES_ROOT\David.Document\shell\open\ddeexec\application = DAVID
; note: the application is optional
; (it defaults to the app name in "command")
HKEY_CLASSES_ROOT\David.Document = David Document Where David is the name of your application that handles the .dbc extension.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
DDE is just one of three ways that the Shell can invoke a verb. The ddeexec subkey is added to the verb's key to specify that a DDE conversation should be initiated.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I want to do a live update of software, but for some reason,
instead of going to the internet and downloading the file, on some
computers it goes to the temporary internet files folder and
just reloads that file so that it didnt update anything (but
the user thinks it did).
If I manually delete the file from the temporary internet files
folder and click Live Update, then everything works fine. So
my question is: how can I delete a file from the temporary
internet files folder? The file I want to delete, for me,
is:
C:\Documents and Settings\Danielle Brina\Local Settings\
Temporary Internet Files\Multiscreen.txt
But for other people on other computers, instead of my naming
showing up as a subfolder, they are going to have their name.
And I don't know what that is. Is there anyway to know what
this name is or folder is so that I can then go to the
other folders and delete the file?
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
|
|
DanYELL wrote:
instead of going to the internet and downloading the file, on some
computers it goes to the temporary internet files folder and
just reloads that file
Specifying the INTERNET_FLAG_RELOAD flag will force a download of the requested file from the server instead of trying to load a cached version.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I use this code:
hr = URLDownloadToFile ( NULL,
sURL, // URL to get
sFile, // file to store data in
0, // reserved
&callback // ptr to IBindStatusCallback
);
Is there anyway to specify that flag, INTERNET_FLAG_RELOAD, with
the function URLDownloadToFile or so I need to use
CInternetSession to download a file with that flag so that it
bypasses the cache?
Please, any response you can give me will be greatly appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Unfortunately, the flag applies to HttpOpenRequest() and InternetOpenUrl() (among others) but not URLDownloadToFile() .
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I have a MFC App with a Tray Icon. On Right clicking the Tray Icon i get a small 'Exit' menu and then on clicking on that i need to exit the App, but thats not happening, and the second time i click there's an assertion.
On the handler for the Exit button, i call DestroyWindow();
Also i am overloading the WM_WINDOWPOSCHANGED as said in this article.
http://www.codeproject.com/dialog/dlgboxtricks.asp
Any help here?????
Pritam
|
|
|
|
|
Try AfxPostQuitMessage(0) before you call DestroyWindow.
You may even not need to call the latter.
|
|
|
|
|
Try AfxPostQuitMessage(0) before you call DestroyWindow.
You may even not need to call the latter.
And I recommend you to call CDialog::onClose/OnOK instead of DestroyWindow (if u debug into it, you see the framework does more work just destrywindow). If you use SDI/MDI, try to use the mainframe to intercept the exit message, and after u tidy up things, call the baseclass onclose().
|
|
|
|
|
What is the ID of the Exit menu option? Do you have a handler in place for that ID? If so, what are you doing in that handler function?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I tried AfxPostQuitMessage(0) but didn't work.
Basically, i have put a WM_COMMAND handler function where i check if the ID is TRAY_EXIT (thats the id of the Exit Menu option) and try to call AfxPostQuitMessage() there. But nothing happens.
I ran DebugView to capture win32 and ran the app. But DebugView says:
>>routing command id 0x8003 sent to app
>>IGNORING command id 0x8003 sent to Cdialog Dialog
(0x8003 is the TRAY_EXIT number)
Is there a better way to handle creating a menu and providing exit option and then handling it??????
Looks like i am missing something here............
Pritam
|
|
|
|
|
pritamkd wrote:
I tried AfxPostQuitMessage(0) but didn't work.
If you are simply wanting to exit your application, just send it a WM_CLOSE message. If it is a dialog-based application, call EndDialog() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hey Folks!, i got the idea!
i didn't have a proper handler in place for the TRAY_EXIT message. My bad!!!
Anyway , thanks a lot for your help!!!!
Pritam
|
|
|
|
|
hi
I am tejaswi . I wanted to read the contents from editboxes of a dialog window. am able to do so except for one edit box. That is apperaring on the screen as if it is read only. but not even able to copy the contents of that one manually. The caret is not coming there even if i click on the box with mouse. please tell how to read contents of it. any property is to be set or what.
Thank you. Tejaswi
|
|
|
|
|
Did you check the edit box 'read-only' setting?
Did you check the DDX_Control has its entry?
Did you call UpdateData(FALSE) at the wrong time?
|
|
|
|
|
y not u delete the control and place a new one?
V
|
|
|
|
|
What does the code look like that is attempting to read from that edit control? Is this an MFC application?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
yes yes it is an MFC application using the Cwnd Class. first of all , the application that has created that edit control is a different one. not under our control. i am j ust trying to read from the window "Histograms" generated by that application( Vims Configuration Tool). I am trying to do this by using available functinos like FindWindow("Histogram"),GetTopWindow(),GetNextWindow().. like that getting all controls and then using SendMessage(WM_GETTEXT...). and now the problem is for the window that is disabled(seems to be i dont know exatly) but data is visible.
i am not even getting a handle to it .some other windows that are disabled i found using a function sth like CSnd:: isEnabled .but in that list also the one i am talking about is not there.
-- modified at 3:27 Friday 23rd September, 2005
|
|
|
|
|
tejaswi_teja wrote:
...now the problem is for the window that is disabled(seems to be i dont know exatly) but data is visible.
Whether a window is disabled or not, you can still read text from it. If you really need to know its enabled state, use IsWindowEnabled() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|