|
Hello,evryone! this is the first time i come to a foreign forum,
I am a chinese, and english is poor, you can realize it from my words. ^_^
i want to learn english and programming here,so it's only a try. please help me over time!
Hello!
|
|
|
|
|
Hi, I wonder what's fastest to check if a child control (hWnd) is visible?
IsWindowVisible(hWnd) -or-
GetWindowLong(hWnd, GWL_STYLE) & WS_VISIBLE
First line checks specified window, its parent window (its parent's parent window and so forth) have the WS_VISIBLE style. Second line checks only the specified window. When I check I already know that parent etc is visible, so is second line the fastest solution?
Thx, Moak
|
|
|
|
|
hm, I'll take GetWindowLong()
|
|
|
|
|
Ok.. I dug out one of my old VC++ books Inside Visual C++ Version 4. I read the section on dlls after post many questions here and I still can't seem to get a pointer to my function. Following is the code I am using if anyone has any ideas it would be appreciated.
Thanks,
-Eric
Created this dll using the dllWizard as a shared MFC regular dll.<br />
This is the only exported function in the dll.<br />
__declspec(dllexport) CString SndMessage(CString strInMessage)<br />
{<br />
CString strOutMessage = _T("Inside TestDll.dll->SndMessage() ");<br />
<br />
strOutMessage += strInMessage;<br />
<br />
return strOutMessage;<br />
}<br />
<br />
This is in the Dialog header file as public.<br />
typedef CString (SNDMESSAGE)(CString);<br />
HINSTANCE hDllHandle;<br />
SNDMESSAGE *fpFunction;<br />
<br />
Inside my OnInitdialog().<br />
hDllHandle = ::LoadLibrary(_T("TestDll.dll"));<br />
if(hDllHandle == NULL)<br />
MessageBox(_T("Error loading TestDll.dll"));<br />
else<br />
{<br />
fpFunction = (SNDMESSAGE *)::GetProcAddress((HMODULE)hDllHandle, "SndMessage");<br />
<br />
if(fpFunction == NULL)<br />
{<br />
MessageBox(_T("Error obtaining address of SndMessage() in TestDll.dll"));<br />
PostMessage(WM_QUIT);<br />
}<br />
}<br />
<br />
void CTestingDllDlg::OnButtonTest() <br />
{<br />
UpdateData(TRUE);<br />
<br />
m_strOutText = (*fpFunction)(m_strInText);<br />
<br />
UpdateData(FALSE);<br />
}<br />
<br />
|
|
|
|
|
The problem is you are exporting a C++ function and its name to the outside world is not SndMessage. C++ mangles the name of functions so that the arguments types are included. If you have successfully built your DLL you can find out exactly what the exported name is by typing "dumpbin /EXPORTS TestDll.dll" Dumpbin is one of the VC++ tools.
One work around is to export a straight C function that exports a pointer to the string that is passed via a LONG and you cast it to a string pointer when you use it. This can be wrapped in a local C++ function so don't see the messy details.
Note - in your current implementation, I believe that strOutMesage will be destroyed when SndMessage returns since it is then out of scope.
The Ten Commandments For C Programmers
|
|
|
|
|
Rick York wrote:
The problem is you are exporting a C++ function and its name to the outside world is not SndMessage. C++ mangles the name of functions so that the arguments types are included. If you have successfully built your DLL you can find out exactly what the exported name is by typing "dumpbin /EXPORTS TestDll.dll" Dumpbin is one of the VC++ tools.
One work around is to export a straight C function that exports a pointer to the string that is passed via a LONG and you cast it to a string pointer when you use it. This can be wrapped in a local C++ function so don't see the messy details.
When I run Dumpbin this is what I get:
Dump of file TestDll.dll
File Type: DLL
Section contains the following exports for TestDll.dll
0 characteristics
3E1E3F7D time date stamp Thu Jan 09 22:35:25 2003
0.00 version
1 ordinal base
0 number of functions
0 number of names
ordinal hint RVA name
Summary
F000 .data
5000 .idata
11000 .rdata
C000 .reloc
4000 .rsrc
10F000 .text
Rick, any chance you can explain the second part of that to me?
Thanks,
-Eric
|
|
|
|
|
It sounds to me like you need to use a .def file. I'm not positive, but if it's the GetProcAddress that's failing, this is probably the case.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
Change:
__declspec(dllexport) CString SndMessage(CString strInMessage)
to:
extern "C" __declspec(dllexport) CString SndMessage(CString strInMessage)
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I think this would help but I think the CString created will be gone once it is out of scope. I think the CString needs to be new-ed and passed as a pointer.
The Ten Commandments For C Programmers
|
|
|
|
|
What is OLE object? How to create it in VC++?
|
|
|
|
|
|
Can someone please help!!
When I try and displays numbers in hex using the setf(ios::hex) member function of the cout stream class with the string class header defined the numbers do not display in HEX.
the following code works and the number display correctly in hex
#include <iostream.h>
//#include <string>
//using namespace std;
int main()
{
int x = 0xff;
cout<<x<<endl;
cout.setf(ios::hex);
cout<<x<<endl;
return 0;
}
but when i try this the number does not display in hex
#include <iostream>
#include <string>
using namespace std;
int main()
{
int x = 0xff;
cout<<x<<endl;
cout.setf(ios::hex);
cout<<x<<endl;
return 0;
}
Can someone please explain???
thanks
-perseus
|
|
|
|
|
Use an I/O manipulator for that:
cout << hex << x << endl;
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
thanks for your help. i knew it had to be something simple
-perseus
|
|
|
|
|
Hi All,
anybody know of some spots on the web to find icons I can use in my programs?
Thank You
|
|
|
|
|
http://www.iconarchive.com
http://www.iconnews.freeserve.co.uk/page2.html
http://www.iconfactory.com
http://groups.yahoo.com/group/glyphs/messages
Should be enough to get ya started
And the clickety police can sod off!
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
|
Hi guys!
I'm a beginner and I have some problems with the project I am working. It's a MDI without doc/view.
I just want to know how I can use a splash screen. I have read that there was a splash screen component in VC++ 6 but I cannot find it in .NET. Also, I want to change the icon and the title of my child windows. I've been able to change the size and the position of my child windows but I can't change the name and the icon.
I used
BOOL OpenGL_ContextMFC::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying theCREATESTRUCT cs
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
cs.lpszName="My new name here doesn't work";
cs.cx = 500;
cs.cy = 500;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
}
any ideas?
thanks
|
|
|
|
|
Yup there is a splash screen component in VC 6....its very simple to use...
I dunno why u need in .NET.
Then to change the Icon..Its simple...Replace the icon which u want to load with the existing thing in the resource file(.rc)...and i dunno which name ur talking abt.....So be more forthcoming...
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
I have a dialog app that I use to call other dialogs to display and get information.
When a user presses a button I call up a dialog like so:
CMALF2Dlg *pdlg;
pdlg = new CMALF2Dlg;
pdlg->Create(IDD_MALF_2,this);
and when I close the dialog I use:
DestroyWindow();
PostNcDestroy();
delete this;
After doing this it deletes some of the memory, but leaves about 4k out there. After calling and closing a few times it seems to settle at two memory values one before the call and one after. Is this normal or am I missing something here? Maybe I'm missing some other memory management code.
Thanks for the help,
Jim
|
|
|
|
|
Hmmm, delete this should take care of everything, including calling DestroyWindow window, so there's no need to call it yourself.
Anyway, the reason for the memory leak is not apparent, but if you run the app in the debugger and then close it, you should see exactly where the memory that's leaking was allocated.
You may also consider taking a different, simpler approach. But it depends on whether you want to allow the user to create multiple CMALF2Dlg boxes everytime the button is pressed. If you DON'T, then great! I have the perfect solution, create it as a static variable:
static CMALF2Dlg s_dlg;
if (!::IsWindow(s_dlg.m_hWnd))
s_dlg.Create(CMALF2Dlg::IDD, this);
s_dlg.ShowWindow(SW_SHOWNORMAL);
Then you can get rid of the delete this as well as the memory leak.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Hi!
I want to make a system call to run a C executable from my another c code.
How can I do that?
Thanks
|
|
|
|
|
You have several alternatives, from simplest to most complex:
1. system
2. WinExec
3. CreateProcess
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
I think My problem is So Basic.
i explain my problem again!
i have a SDI MFC project. i define an Modless Dialog Box and Show it beside the Main Document Window.i define it in CDemoView (My Main Class of Project) i can Set properties of that Dialog's Controls for Example i can Set the Caption of a Static-Text object that Exists in that Dialog Box.
So my problem is i Still Can't Capture Events of that Dialog Box Buttons.
for example if i Click a Button in that Dialog i can't Send_Message to CDemoView or Call a Function of CDemoView.
if i add an Event handler of that Button in CDemoView it will don't respond.i should add Event Handler only in that Dialog Class to respond. (i donno Why Event Handler Shows another Classes when i choose event handler for that Button . becouse only Dialog Class Responds to Events)
my another Quiestion:
i know that i can Define an Object of Current CMainFrame Class's object:
CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());<br />
pFrame->HidePalette();
how can i Define an Object of CDemoView Class Like this. in this code if i change CMainFrame to CDemoView an Error Occurs : Debug Assertion Failed.
thanks Anyway,
|
|
|
|
|
ok here we go
in ur dialog box button message handler have something like:
PostMessage(AfxGetMainWnd(),WM_USER+10,0,0)
in ur main window have a message map entry for that message that processes the button click
just remember ur getting the message in the dialog from when the button is clicked and sending a message to another part of ur app to deal with it
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|