|
Short answer: no
long answer: It can be done, but it's very tricky to rip a single class out of MFC; and adding full MFC support to the project is probably not what you want either.
|
|
|
|
|
Hi,
My problem is that I have to write a function that will at runtime accept a name of a dll and a name of a function contained in that dll and then call that function. The obvious problem is that a compile time we don't know the return type of a function be be called and the number and types of arguments to be passed to the dll.
My guess is that we'd have to use assembler code in __asm blocks to pass any number of parameters of any types by manually pushing them into the stack.
But then of what type do I declare the function pointer that will take the adress of function returned by GetProcAddress?
Any Answers/Suggestions?
Thanks in advance,
Mvworld
|
|
|
|
|
Hello, the codegurus around the world.;)
In fact, I don't know what your assembler code does?
But, if the assembler code can call Java class, you can use JINI to call DLL
file which you created.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Hi,
I have been trying to use run time linking with Dll files. I am new to Windows programming, so I am confused what is causing the error in my program.
I am trying to use run time linking to change the Window Title of a Console widow.
Here is the code:
#include
typedef BOOL (WINAPI *LPFNDLLFUNC) (HINSTANCE hInstance, char *dwText);
void main()
{
HINSTANCE hLibrary;
LPFNDLLFUNC lpfnDllFunc;
BOOL RetVal;
char dwString[] = "Changed Text";
HWND hwnd;
char pszWindowTitle[40];
GetConsoleTitle(pszWindowTitle, 40);
hwnd = FindWindow(NULL, pszWindowTitle);
hLibrary = LoadLibrary("USER32.DLL");
lpfnDllFunc = (LPFNDLLFUNC) GetProcAddress(hLibrary, "SetWindowText");
RetVal = lpfnDllFunc(hLibrary, dwString);
}
It compiles and links fine, but it performs an illegal operation on running it.
On debugging I get the following message:
Unhandeled exception in Testing.exe:OxC0000005:Access Violation
Any ideas?
|
|
|
|
|
Hello, the codegurus around the world;)
First of all, I don't know the exact answer, but
have you ever written C or C++ code?
>> I am new to Windows programming.
So, you know C?
I mean, why don't you use if-else statement to check if the function returns the right value.
1) Check if FindWindow works fine?
2) If 1) works, go to 3)
3) Check if LoadLibrary works fine?
4) If 3) works, go to 4)
5) Check if GetProcAddress works fine?
6) If 5) works, go t 7)
7) Try to use SetWidnowText(...)
I think that any programmer needs this kind of approaches even though we use Java or C++.
Anyway, I think that SetWindowText's first arguement passes HWND, not HINSTANCE?
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Have you traced through the code yet? You'll see that lpfnDllFunc is NULL. That's because there is no function "SetWindowText". There are "SetWindowTextA" and "SetWindowTextW" for ANSI and Unicode, respectively. Your code is using plain chars, so use the ANSI version.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Hi mate,
Yeah I took note of it, just careless mistake I suppose.
Thanks a ton though
|
|
|
|
|
FindWindow(A/W) and SetWindowText(A/W) both lives in user32.dll. If you are using FindWindow using static link, why do you need runtime linking for SetWindowText?
|
|
|
|
|
This problem is a part of a larger study problem I have for my college project.
I am basically experimenting with all the calling conventions etc...and this will finally be used in code for XEmacs, which is a unix originated text editor.
|
|
|
|
|
How can I implement an application to send data over a network (by using a custom-made OLEDB provider) the same way commercial DBMS communicate with data consumers?
Ernesto Moscoso Cam
|
|
|
|
|
Hi All,
I have a BSTR string variable via ADO Recordset Getstring method. In the BSTR string has null
character('\0'). How can I get rid them of in a common way(Of course I can loop from start of
BSTR, but I want a directly way).
Thank you.
chenzhu
|
|
|
|
|
Hello, the codegurus around the world.;)
In fact, I don't understand your question a little bit.
Do you want to take off "NULL" word from Column (display)?
Or do you want to take off '\0' from all strings in Column?
Or I miss something?
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Dear Masaaki Onishi,
The last effect is my desire. I get a BSTR string has '\t' separator between columns and '\n'
between rows. But int the string has excaptional '\0' just before a '\t'. I can not transform
it to CString by W2A or WideCharToMultiByte functions directly because these annoying '\0'.
Thanks.
chenzhu
|
|
|
|
|
Hello, the codegurus around the world.;)
Do you try to use ADO in MFC or COM(ActiveX)?
If you use ADO in MFC, we can use DataGrid control and this member function to display the data.
As a result, we don't need to care about each data string.
I often use Datagrid for ADO in MFC.
Actually, MSDN has a good example called AdoDataGrid(?).
However, if you want to use CListView or something to display your data, you may need to work
your problem.
Anyway, I want to sleep now.
So, someone migh help you, or if I have a time....
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Dear Masaaki Onishi,
Thank you very much. Yes, I want a control to display the data. Actualy I am making a ATL control and the ATL control hold one Grid that accept format string in that pattern. The
common usage is a VB project, which is the client of ATL COM control, opens one database
and get one recordset, and then pass it into ATL control. Of course I can loop through whole
recordset, read variant from every fields and assemble a CString by myself, but that is
too tiresome.
If you have waked up now has have a good mood, give me a advice.
thank you.
chenzhu
|
|
|
|
|
Hi do anyone know how to link a file in C++ whith a line of code like #pragma or something... I don't want to set it in the project settings box...
|
|
|
|
|
Try this:
#pragma comment(lib,"something.lib")
|
|
|
|
|
|
can you help me to add an icon to a CFileDialog
|
|
|
|
|
Hello, the codegurus around the world.;)
We can derive CMyFileDialog from CFileDialog class, and
put the some code to create icon in CMyFileDialog::OnInitDialog().
Good luck.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
hi all,
I am using VS-FlexGridPro Version 7 (A product from VideoSoft & Bunka Orient Corp.) in my project. This is an ActiveX Control similar to MSFlexGrid but it provides more facilities than MSFlexGrid.
i have a problem in this, i have to add check boxes in first column of the Grid Control. but there is no property to set for check boxes.
if anyone know aboout it then please reply asap.
Thanks
Nitin
|
|
|
|
|
I think you must define the column type as boolean.
VsflexGrid will display check boxes.
|
|
|
|
|
Hello Erik,
To continue on the topic of dynamic toolbands and XML:
As I told you, I'm writing a similar app. The problem is with parsing the XML. I tried to use Ben Bryant's CMarkup class, but it says that XML is not well formed no matter what I do.+ I'm a COM programmer and would like to use MSXML parser to parse the XML. I do have a XML parsing class, taken much after Stingray's OTL toolkits XML class. The problem is in searching the XML tags. It can only find the first matching tag but not beyond it. Look, I know you must be very busy writing a gadzillion of articles for guys like me, but I would like you to lookover my XML class and suggest improvements. Of course I can't post it to you right away, but well, I give you fair warning!
Anyway, for the toolband the general idea is to create a toolband and embed a toolbar(rebar)in it. On OnCreate of toolband, I create my buttons with relevant icons and text. This occupies half of the toolband's area. In the other half I would like to dynamically create buttons based on XML data. After the toolband's created it retrieves an XML file from the web server and parses it. Then in accordance with the data it creates buttons(links really). on clicking buttons I just call Navigate()on the interface I get from SetSite() to navigate to the appropriate url. I'm using a stl class to store URLs.
Is this what you are doing too?
Also, if you have seen Yahoo companion, you'd know the kind of dropdown buttons I'm talking about. basically dropdown with tracks states too. Is there already any class like this here at CP? I really don't wanna code the button class from scratch,unless I have to. What's the easy way out?;P
TIA.
|
|
|
|
|
Since you're doing just simple parsing, you can use MSXML 1.0+ which ships with IE5+ (Maybe even IE4,IE4.01). To check to make sure you have valid XML just open the file in IE and see if it loads properly. Dynamic and static buttons are both obtainable. You can simplify it with 2 toolbars or fanagle it with 1 toolbar making sure not to overlap button ID's. How you are planning to do it is the way I have already done it.
As for the yahoo companion question about menu states, I don't have any information on that.
-Erik
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
For your XML parsing problem, have you checked out the IXMLDOMNode::selectNodes() method?
|
|
|
|