|
AFAIK you also have to use __stdcall calling convention.
Does your WIN32DLL02_API already contain it?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Hi Pallini,
jap you are right __stdcall is in WIN32DLL02_API but i could not manage this, is it possible for you to insert the lines in the code ?
I know that is not a "rent a coder", but i have the worst prob with this Dll since ... !!!
When I use This Code I get an "a" not "abc" and i culd not pass a Strin parameter to the function fnWin32Dll02(void), when I try it(shure with a LPCSTR or a BSTR param. in the function interface) i get an Error, pleeeese help me it's horror !
<br />
WIN32DLL02_API BSTR fnWin32DLL02(void)<br />
{<br />
<br />
BSTR s;<br />
<br />
s = SysAllocString(L"abc");<br />
<br />
return s;<br />
}<br />
<br />
Option Explicit<br />
<br />
Private Declare Function fnWin32DLL02 Lib "E:\WORKING\OMRON\GDT\EigeneDLL\Übergabe eines Strings aus C++ Dll\Win32DLL02.dll" () As String<br />
<br />
<br />
Private Sub Form_Load()<br />
<br />
Dim x As String<br />
<br />
x = Space$(6)<br />
x = fnWin32DLL02()<br />
MsgBox "X ist: " & x<br />
<br />
End Sub<br />
<br />
Many thx hopefully and best regards
Croc
|
|
|
|
|
I'm a tenacious guy... Eventually I was able to make some test using VB and VC++6.
The code:
DLL header
#ifdef DLLSIMPLE_EXPORTS
#define DLLSIMPLE_API __declspec(dllexport)
#else
#define DLLSIMPLE_API __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C"
{
#endif
DLLSIMPLE_API BSTR __stdcall fnHello(void);
#ifdef __cplusplus
}
#endif
DLL source (.cpp )
#include "stdafx.h"
#include "oleauto.h"
#include "DLLSimple.h"
DLLSIMPLE_API BSTR __stdcall fnHello(void)
{
LPCSTR pChar = "hello VB!";
BSTR bstr = SysAllocStringByteLen(pChar, strlen(pChar));
return bstr;
}
VB source
Private Declare Function fnHello Lib "DLLSimple.dll" Alias "_fnHello@0" () As String
Private Sub Form_Load()
Dim s As String
s = fnHello
MsgBox s
End Sub
Hope that helps
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
What I usually do in these cases is 'force' my VB brethren to use strings and counters.
<br />
<br />
Public Declare Function fnWin32DLL02 lib "whatever.DLL" ( ByRef SomeString as String, ByVal SomeLength as Long ) As Long<br />
<br />
Dim x As String<br />
DIM y As Long<br />
Dim z As Long<br />
<br />
x = Space$(3)<br />
y = 3<br />
z = fnWin32DLL02(x,y)<br />
Then the C interface becomes
<br />
long __stdcall fnWin32DLL02(char** pbuffer, long nBufferCount)<br />
Just make sure you space fill the buffer up to nBufferCount.
|
|
|
|
|
Thx Pallini and Chis,
it works, but i had to change the ByRef to Byval Chris !
Thx a lot
Croc
|
|
|
|
|
Hi all,
I would like to know whether there is a way that one can keep a table in memory, so that there is no need to read from a db table.
Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
|
thanks for the response I'll have a look
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
isn't what a CResultset made for ?
by the way, keep in mind that your database datas may be modified by another process (i consider the common case when the DB is remote, with several clients querying on it). so if one client stores its query result, without ever refreshing them by times, you may have not synchronized data.
|
|
|
|
|
toxcct wrote: isn't what a CResultset made for ?
DataTables are made for. (Un)fortunately they belongs to the managed realm.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
I have 3 combo boxes in my application. and this 3 combo boxws indicate opening a folder and logging the data. the existing system is like whenever the appliaction is opened, it starts loggin in the data. i dont want to do that. now what i want to do is when i check one of the check box it should start loggin in in one folder and it has to be done during runtime. what can be done for this?
|
|
|
|
|
And what is the problem, aren't you able to handle check boxes events?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
i am sorry for not completing the query. i am initiating a socket. when i enable the socket a message gets passed to a folder. this is already there in the application. now i need to log this message whenever i need. for this i am using a check box. if i click the check box the message should get logged in. if i dont check the check box the message should not get logged in. and i should be able to do this when the socket is on. i need to know how can it be done. i hope the problem is clear now.
|
|
|
|
|
In fact the scenario is clear now. But I still don't know
(1) How the logging (and reading) is actually performed by the code (e.g. have you threads, what object manages logging, and so on)
(2) What is your difficulty.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
cool... its a button which helps to activate the socket and the same way to deactivate the socket. so when its activated and deacticated it will send a message. and its gets logged into a folder. i want to do it dynamically...
i am not being able to loggin the data to the folder.
|
|
|
|
|
I think you'll need to post some code.
Anyway, why don't you bind the logging message to the checkbox (removing it from the socket activation routine)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
i can try that. and will put some piece of code also.
|
|
|
|
|
Hi,
i have subclassed one comboobox in my application using the following code
<br />
LONG FAR PASCAL SubClassFunc(HWND hWnd, UINT Message, WPARAM wParam, LONG lParam);<br />
FARPROC lpfnOldWndProc;<br />
<br />
BOOL NcClass::OnInitDialog() <br />
{<br />
cbi.cbSize = sizeof(COMBOBOXINFO);<br />
GetComboBoxInfo(m_SignalsLabel_ctl.m_hWnd, &cbi);<br />
pfnOldWndProc = (FARPROC)SetWindowLong(cbi.hwndItem, GWL_WNDPROC, (DWORD)SubClassFunc);<br />
return TRUE;<br />
}<br />
<br />
LONG FAR PASCAL SubClassFunc(HWND hWnd, UINT Message, WPARAM wParam, LONG lParam)<br />
{<br />
if(Message == WM_KEYDOWN)<br />
{<br />
if(wParam == VK_TAB)<br />
{<br />
HWND hChild, hParent;<br />
hParent = ::GetParent(hWnd);<br />
hChild = ::GetWindow(hParent, GW_HWNDNEXT);<br />
::SetFocus(hChild);<br />
}<br />
}<br />
<br />
if( Message == WM_GETDLGCODE )<br />
return DLGC_WANTTAB;<br />
<br />
<br />
return CallWindowProc(WNDPROC(lpfnOldWndProc), hWnd, Message, wParam, lParam);<br />
}<br />
Even though i am calling CallWindowProc()from my window procedure, mouse click and other thing are not woking for the combobox which i have subclassed and application is having some effect on other comboboxes also.
I have also tried by commenting the whole code of SubClassFunc() except the last line, but still the behaviour of application is same.
My problem is that i can't create seperate class for the combobox.
Thanks.
|
|
|
|
|
You mean even if the code is just as below, it is not working?
LONG FAR PASCAL SubClassFunc(HWND hWnd, UINT Message, WPARAM wParam, LONG lParam)
{
return CallWindowProc(WNDPROC(lpfnOldWndProc), hWnd, Message, wParam, lParam);
}
Are your sure that you need to subclass the edit control in the combobox?
If yes, are you sure that the combobox is having dropdown style (having edit box inside)?
|
|
|
|
|
Yes, it is of DropDown style only and i am doing all this just to move the focus. For other combobox of style DropList type the tab key is working fine.
I am sending message from some other class to the dialog containing the combobox to set the focus.
Thanks
|
|
|
|
|
ashtwin wrote: I am sending message from some other class to the dialog containing the combobox to set the focus.
How are you sending the message? Code fragment will be helpful.
|
|
|
|
|
Hi, from the function below i am sending the message.
<br />
BOOL MyBaseClass::PreTranslateMessage(MSG *pMsg)<br />
{<br />
HWND hParent, hChild;<br />
if(::FindWindow(NULL, _T("My Dialog")))<br />
{<br />
if(pMsg->message == WM_KEYDOWN)<br />
{<br />
if(pMsg->wParam == VK_TAB)<br />
{<br />
hChild = ::GetFocus();<br />
hParent = ::GetParent(hChild);<br />
::PostMessage(hParent, WM_MYMESSAGE, 0, 0); <br />
}<br />
}<br />
<br />
}<br />
return MyBaseClass::PreTranslateMessage(pMsg);<br />
}<br />
I am doing this because due to some reasons the keyboard messages are going to the above function.
MyBaseclass is the class from the child class of whom i am creating the modeless dialog.
modified on Monday, January 07, 2008 8:31:43 AM
|
|
|
|
|
First of all, are you missing the call to base class's PreTranslateMessage ?
PS:
The following should be noted.
if(::FindWindow(NULL, _T("My Dialog")))
{
if(pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam == VK_TAB)
{
is not good. Change as follows...
if(pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam == VK_TAB)
{
if(::FindWindow(NULL, _T("My Dialog")))
{
|
|
|
|
|
Ok, thanks i will change my code as u have suggested. But i am calling the base class PreTranslateMessage.
Thanks
|
|
|
|
|
ashtwin wrote: return MyBaseClass::PreTranslateMessage(pMsg);
OK...
ashtwin wrote: ::PostMessage(hParent, WM_MYMESSAGE, /*pMsg->wParam*/0, /*pMsg->lParam*/0);
I think this WM_MYMESSAGE is WM_USER + nonzero message, right? If so what is the exact value?
Or it a registered message?
Also did you tried by excluding the subclassing done in the InitDialog, but keeping this MyBaseClass::PreTranslateMessage function as now?
|
|
|
|