|
Hi
I am developing a MDI application where I would like to be able to control
the activeChild form from buttons on the MdiParent toolbar.
For example navigate through records in the dataset of the activeChild form.
I would like to use the same buttons on the MdiParent tool bar for any
activeChild form that is open.
How would I accomplish this? (C#/C++ please)
Thanks,
JoseTA
FranTA
|
|
|
|
|
Hi,
I have been succesful using single statement of DllImportAttribute to use my unmanaged Dll code. But, now I want to have 2 entrys in my Dll, so I wrote two DllImportAttribute Statements:
[System::Runtime::InteropServices:llImportAttribute
("D:\\Tumego\\MultiWayTree\\VBMGUM_DLL\\Debug\\VBMGUM_DLL.dll", _
CharSet =CharSet::Auto)]
extern int GetValue1000(void);
//
[System::Runtime::InteropServices:llImportAttribute
("D:\\Tumego\\MultiWayTree\\VBMGUM_DLL\\Debug\\VBMGUM_DLL.dll", _
CharSet =CharSet::Auto)]
extern int GetValue99(void);
The Error messages are:
BMGUM_MG.cpp(16) : error C2363: ?argument? '"_\r\nCharSet"="CharSet::Auto"' (?Custom Attribute? 'System::Runtime::InteropServices:llImportAttribute') ?Can not be evaluated?
VBMGUM_MG.cpp(13) : error C3725: 'System::Runtime::InteropServices:llImportAttribute': ? Can not interpret overloading of attribute?
?it might be ?'System::Runtime::InteropServices:llImportAttribute:llImportAttribute(System::String __gc *)'
*****?----? is not exact but is translated from Japanese Version Visual Studio ***********
Writing multiple DllImportAttribute Statement like this is fine:
even I can use using namespace:
using namespace System::Runtime::InteropServices;
[DllImportAttribute("Kernel32.dll", CharSet=CharSet::Auto)]
extern "C" int QueryPerformanceFrequency(__int64* Freq);
[DllImportAttribute("Kernel32.dll", CharSet=CharSet::Auto)]
extern "C" int QueryPerformanceCounter(__int64* Tw);
I do not like Dll expression of "D:\\Tumego\\MultiWayTree\\VBMGUM_DLL\\Debug\\VBMGUM_DLL.dll", becasuse of manageing difficulty. But I do not know other way. May be this expression is the reason for trouble.
The rest of the codes:
DLL simplified finnally like this:
int GetValue1000(void)
{
int a = 1000;
return a;
}
int GetValue99(void)
{
int a =99;
return 99;
}
Definition file:
LIBRARY VBMGUM_DLL
EXPORTS
GetValue1000
GetValue99
Any hints, comments and May-be answers are appreciated, as well as final shot.
Please help me.
|
|
|
|
|
Hi
I came to a work around and I thought it may help some having the same problem, I read MSDN >.NET_Framework > Programming > co-operation with Unmanaged Code.
There is a Sample that donot spell 'DllImportAttribute' but spells 'DllImport' also NO 'CharSet=CharSet::Auto' specification.
For the time-being it happend to be OK for me.
After I elliminated 'CharSet=CharSet::Auto', I donot get strange errors.
Thank you.
Chkky
|
|
|
|
|
Hi,
I asked this question before in the VC++ forum, but I think my question was misunderstood. I´ll try it again with more explanation...
I´m making an Windows Form appl. using VC++ .Net 2003. As I start an "Form" is automatically created for me.
Then I want to make my own "MessageBox"-like class (due to interference with the "windows.h" header I cannot use the included MessageBox" properly.)
I go to Project->Add new Item->Windows Form (.NET) and a new "Form" is created, that I want to use as a dialog box, and I add a Label and an OK-button rto it.
In the Forms properties I set:
FormBorterStyle = FixedDialog
MaximizeBox = False
MinimizeBox = False
However, I don´t know which property I must set, or which method to call for making the Form close when I push the OK-button.
Does anybody have a suggestion?
(I display it by calling the ShowDialog() method.)
Apart from that it works as a dialogbox (I know there are probably better ways to solve the problem, but I´m quite new to VC/C++, and this seemed like the easiest way around it)
regards
doneirik
|
|
|
|
|
I believe if you call the button IDOK, it will do this for you. If not, then there's a property for what button is the OK button, but the name escapes me. At least, that's the case in C#.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
For your MessageBox problem...
In stdafx.h just add #undef MessageBoxA or MessageBox don't remember.
To close your dialog take a look at this and I'm going to help you a bit...
// Set the accept button of the form to button1.
form1->AcceptButton = button1;
|
|
|
|
|
Hi
i am right now doing a project on E - Learning Development Tool Software.
I faced some problems on whether to create projects individually first then transfer it into a DLL, or just do the coding in the DLL?
Jingpo
|
|
|
|
|
I thik you should decide wich way works the best for you. Anyway, I would choose creating projects individually.
--Nikola--
modified 7-Dec-20 21:01pm.
|
|
|
|
|
Hi there, can someone tell me where' a syntax error in that code on line 16.
<br />
#pragma once<br />
<br />
using namespace System;<br />
using namespace System::Windows::Forms;<br />
using namespace System::Collections;<br />
using namespace System::Net;<br />
using namespace System::Net::Sockets;<br />
using namespace System::Data::Odbc;<br />
using namespace System::Text;<br />
<br />
#include "MessagesCodes.h"<br />
#include "Utilities.h"<br />
<br />
__gc class CServer<br />
{<br />
public:<br />
CServer(TextBox* p_txtServerEvents, TextBox* p_txtUsersMessages);<br />
~CServer(void);<br />
<br />
void DecodeMsg(SocketChatClient* p_client, String* p_msg);
<br />
String* GetServerName();<br />
String* GetServerAddress();<br />
int GetServerPort();<br />
<br />
bool GetHost();<br />
void CreateSocket();<br />
<br />
void OnConnectRequest(IAsyncResult* p_ar);<br />
void NewConnection(Socket* p_clientSocket);<br />
void OnReceivedData(IAsyncResult* p_ar);<br />
<br />
private:<br />
String* m_hostName;<br />
IPAddress* m_addr;<br />
const static int PORT= 3050;<br />
Socket* m_serverSocket;<br />
ArrayList* m_arrClients;<br />
TextBox* m_txtServerEvents;<br />
TextBox* m_txtUsersMessages;<br />
<br />
__gc class SocketChatClient<br />
{<br />
public:<br />
SocketChatClient(Socket* p_sock);<br />
<br />
Socket* GetSock() { return m_sock; }<br />
void SetupReceiveCallback(CServer* p_server);<br />
Byte GetReceivedData(IAsyncResult* p_ar)[];<br />
<br />
private:<br />
Socket* m_sock;<br />
Byte m_byBuff[];<br />
};<br />
};<br />
I think the problem is that the compiler don't see the internal class SocketChatClient but I don't know how to correct it.
--------------
The Thruth Is Out There
|
|
|
|
|
have you tried moving the definition of SocketChatClient to the beginning of your CServer class?
that way it is defined before it is referenced...
__gc class CServer
{
__gc class SocketChatClient
{
public:
SocketChatClient(Socket* p_sock);
Socket* GetSock() { return m_sock; }
void SetupReceiveCallback(CServer* p_server);
Byte GetReceivedData(IAsyncResult* p_ar)[];
private:
Socket* m_sock;
Byte m_byBuff[];
};
public:
CServer(TextBox* p_txtServerEvents, TextBox* p_txtUsersMessages);
~CServer(void);
void DecodeMsg(SocketChatClient* p_client, String* p_msg);
String* GetServerName();
String* GetServerAddress();
int GetServerPort();
bool GetHost();
void CreateSocket();
void OnConnectRequest(IAsyncResult* p_ar);
void NewConnection(Socket* p_clientSocket);
void OnReceivedData(IAsyncResult* p_ar);
private:
String* m_hostName;
IPAddress* m_addr;
const static int PORT= 3050;
Socket* m_serverSocket;
ArrayList* m_arrClients;
TextBox* m_txtServerEvents;
TextBox* m_txtUsersMessages;
};
Steve
|
|
|
|
|
Ok it work now... never knew it could be such a that stupid!!!
thx
--------------
The Thruth Is Out There
|
|
|
|
|
I have some custom MFC controls that have been written over the past several years right now (and no, these are not ActiveX or COM components. These are straight-up MFC classes), that the powers-to-be does not want to invest the time to rewrite as .NET components.
Before attempting to use the more complex custom controls, as an experiment, I was able to succesfully compile and link a DLL/assembly that would put up a CListCtrl (yes, I konw there is a WinForm equivalent, but this is an experiment, to see if I can at least get a common MFC control to appear in a .NET app). Unfortunatly, when I run the program, it crashes with a "Debug Assertion Fail" error, when a function AfxGetInstanceHandle is called inside the MFC "Create" function for the CListCtrl.
A seperate DLL/assembly which is essentaly a wrapper around the MFC control is used. A reference to the assembly is incuded into the main app in which to try to display this MFC control.
I've searched the this forum as well as the internet as a whole and I've yet to find a good example of just how to embed an MFC control inside of a .NET application.
I've seen/found examples of how to call the .NET framework from inside of an MFC application, but I have not seen it the other way.
I've also seen/found examples of how to create managed wrappers around unmanaged classes, but none of the examples show how to do it around an MFC class.
Has anybody attempted anything like this, and more importantly, has anybody manage to actually get it to work? I'd like to know just how, preferably with a good example, to get an MFC control to work inside of a .NET application.
Thanks
|
|
|
|
|
|
I've seen that before. It shows how to call .NET from an MFC app.
However, I am trying to call MFC from a .NET (managed C++) app, of which I've not seen any examples, nor anybody with a working solution demonstrating such.
I am wondering if it is even possible.
Thanks for the help, though.
|
|
|
|
|
you can not use many classes, such as CWnd derived classes without a CWinApp object. So the better way is to create an MFC app and then add .Net support.
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
Thanks. I was afraid of that. Now that I think about it, it does make sense.
I guess that would explain the ASSERT errors coming out of AfxGetInstanceHandle. Looking up in the MSDN to see just what AfxGetInstanceHandle does, it is returning an instance of the current application, which I am assuming would be an instance of CWinApp. If there is no instance of a CWinApp being created, than there would be no handle for AfxGetInstanceHandle to return.
Again, thanks!
Well, it looks like in this case, we may have to ditch .NET and go back to MFC, as we got way to much invested in custom MFC controls to have to go back and re-write them to work with .NET. Tis a shame, as there are some nice features in .NET that I'd like to take advantage of.
|
|
|
|
|
Update:
I found this article right here on the Code Project site that shows exactly what I want to do.
I'll try to incorporate what I read in that article into my own project and see if I can get it to work for my needs.
Thanks
|
|
|
|
|
|
Please visit "http://www.codeproject.com/useritems/MFCDotNetApp.asp;P;P"
|
|
|
|
|
Hi,
I have a "SplitterAdvanced" user control, used to load ActiveX and User Control at runtime.
My "SplitterAdvanced" need to be able to load any User controls.
How I can do that ?
Thank
Regards,
Martin
|
|
|
|
|
Please help me with this. I want to extract the information about subsequent pages using this function
VirtualQuertEx()but i don't how i can go about it.
<br />
PROCESS_INFORMATION pi; <br />
STARTUPINFO si; <br />
HANDLE hProcess; <br />
BYTE buf[20000];<br />
DWORD NumberOfBytesRead = 0;<br />
DWORD bufsize = sizeof buf;<br />
DWORD baseaddr = 0;<br />
DWORD lpAddr = 0;<br />
PMEMORY_BASIC_INFORMATION lpBuffer = 0;<br />
DWORD dwLength = 200000;<br />
DWORD flNewProtect =0;<br />
PDWORD lpflOldProtect = 0;<br />
DWORD dwSize =0;<br />
LPCVOID lpBaseAddress = 0;<br />
DWORD nSize = 0;<br />
<br />
VirtualQueryEx(<br />
hProcess,
&lpAddr,
buf,
sizeof (MEMORY_BASIC_INFORMATION));
<br />
VirtualProtectEx(<br />
hProcess,
lpAddr,
dwSize,
flNewProtect,
lpflOldProtect );
<br />
ZeroMemory(buf, sizeof(buf));<br />
if( ReadProcessMemory( hProcess, lpBaseAddress, buf, bufsize, &NumberOfBytesRead ) == FALSE )<br />
{<br />
printf("\nProcess ID %d ",pi.dwProcessId);<br />
printf (" memory read failed (errcode: %d)", GetLastError());<br />
}<br />
else<br />
{<br />
printf("\nProcess ID %d ",pi.dwProcessId);<br />
printf("memory read: \n",buf);<br />
GetLastError());<br />
}<br />
How can i retrieve the buff size from that function
oam
|
|
|
|
|
How to display chinese characters in MessageBox?
How to display Chinese characters in graphic object (GDI)?
Karl
|
|
|
|
|
|
Hi
I am having a problem getting sprites to display. The thing is they display fine if I'm running in debug mode but if i run the app from the .exe they do not appear.
I'm using DirectX 9.0c October version. And have three display windows two of which have sprites being rendered to them.
The sprites are being Draw or at least no exceptions are being thrown in the Draw2D call but nothing is appearing
if anyone has any ideas your help would be greatly appreciated. Its driving me nuts.
samn
|
|
|
|
|
How feasible is it to use interprocess comunication for an input for a compiled c++ program? Even if I had to write an include file that would then require the user to use a little diffrent syntax for input and output, but it would need to be as easy for the programer to include it and then use input>> or output<<...
I am trying to have an aplication open on a server, that is interactive. The user would program a c++ document, then could use the online window to test it and it would actualy get all of it's data from the users .exe file that was written. The user would be able to give the location on the system to the server.
any idea as how it could be done?
|
|
|
|