|
Hello, in my aplication there are two dialogs CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this?
I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or SendMessage , but in DlgMap1 how can i get the hWnd to CCalibracionDlg?
Thanks in advance.
|
|
|
|
|
How and where in the code are you creating CCalibracionDlg?
You must be having the object of CCalibracionDlg in your appplication. Why cant you share it with DlgMap1 class?
|
|
|
|
|
well i dont think sendMessage is a good option if they are belonging to the same application and thread.
one method will be use FindWindowEx, that give you the handle if you specify the name of the dialog.
Величие не Бога может быть недооценена.
modified on Thursday, October 22, 2009 12:53 AM
|
|
|
|
|
CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this?
I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or
Better to have an 'object' or pointer of CCalibracionDlg in DlgMap1.U can get handle through object.GetSafeHWND(). Or Simply u can call object.SendMessage(..) or object.PostMessage()
--Cool_Dev--
|
|
|
|
|
The objet from i'd like send the message is CDlgMap1 to the objet CCalibracionDlg, so you say that i have to put this code in the apropiate function in CDlgMap1 : CCalibracionDlg.PostMessage(...)?
|
|
|
|
|
yeaa.. exactly. As you want to send message to a window from another window in same application, u can simply use a Callback or a direct function call. But if the situation needs, such as you need to call the function many times, its better to use PostMessage or sendMessage.
--Cool_Dev--
|
|
|
|
|
Well , thanks to all, finaly i get the solution with:
GetParent()->PostMessage(WM_MyMessage,NULL,NULL);
|
|
|
|
|
timbk wrote: ...when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this?
Are they both visible? Are they modal or modelsss?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Ies they are both visible, the one from class CCalibracionDlg is modal and the one from CDlgMap1 is no modal, why?
|
|
|
|
|
timbk wrote: ...the one from class CCalibracionDlg is modal and the one from CDlgMap1 is no modal, why?
Because modal dialog boxes "block" other windows from processing messages. Your topmost dialog would need to be modeless if you want it to be able to communicate with the dialog below it.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
oh, I didn't know it , so it's imposible send and recive messages between a model and modeless? ok supose that i change the main dialog to modeless , how can i do te send or post a message between the two modeless? with PostMessage?
|
|
|
|
|
timbk wrote: so it's imposible send and recive messages between a model and modeless?
No, it IS possible.
timbk wrote: ok supose that i change the main dialog to modeless...
The main dialog should stay modal. Any subsequent dialogs that you want to communicate with it should be modeless.
timbk wrote: ...with PostMessage?
That's a different topic altogether, and at this point does not matter to you.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks. But , wich is the correct syntax? i wrote the following code in CDlgMapa1
<code>CCalibracionDlg.PostMessage( ? , WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam);</code>
Two questions:
1-What have i put in'?' ? , the handler to CCalibracionDlg (is the object that recives the message) ? in this case , how can obtain it? if you could put some code like an example , would be nice.
2- at that line of code the compiler says : error C2143: syntax error : missing ';' before '.' , sounds like the compiler doesn't recognizes that line. thanks again.
|
|
|
|
|
Well , thanks to all, finaly i get the solution with:
<code>GetParent()->PostMessage(WM_MyMessage,NULL,NULL);</code>
|
|
|
|
|
Hello,
I am trying to get started with some programming, but I'm getting nowhere with an actual interesting sort of a project.
I can do console examples fine, and follow the instructions on the MSDN, but what I want to do is work on editing and creating modules for a program called SynthEdit.
SynthEdit creates Music software synthesizers, and the software has an SDK released.
So if I can figure out how to load a project/solution file from the SynthEdit SDK and actually successfully compile it, I will be able to actually start working on something.
But I am getting nowhere, because I always get errors when trying to compile.
It should be as simple as installing Visual C++ and the Microsoft SDK, then just loading a file from the SynthEdit SDK and compiling it. But something is not working right.
Visual C++ 2008 installs with Windows SDK version 6.0A already installed and ready to go, right? But it doesn't work. I added the file paths to the VC++ directories for Executable files, Library and Include files, it still doesn't work.
I downloaded Windows SDK v 7.0 and added the paths to the VC++ directories, it still does not work.
So What do I need to do to get a Windows SDK integrated into my Visual C++ 2008, so that I can compile something?
I have seen the Microsoft Blog about using the Microsoft Windows SDK configuration tool, it is no help. It fails to be a straightforward step by step guide, and goes into setting directories using the command prompt window without explaining how exactly to do that. So it is useless for a beginner such as myself.
I am pasting the log for my attempt to compile a project called "AGain" below. If anyone sees exactly what the problem is, that would be great. Please don't spend more than a minute or two, I'll have to eventually figure this out, even if it takes weeks.
Build Log
Rebuild started: Project: AGain, Configuration: Debug|Win32
Command Lines
Creating temporary file "c:\Program Files\se_sdk3\AGain\Debug\RSP0000023362984.rsp" with contents
[
/Od /I "..\se_sdk3" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /Wp64 /ZI /TP "..\se_sdk3\mp_sdk_common.cpp"
"..\se_sdk3\mp_sdk_audio.cpp"
".\AGain.cpp"
]
Creating command line "cl.exe @"c:\Program Files\se_sdk3\AGain\Debug\RSP0000023362984.rsp" /nologo /errorReport:prompt"
Creating command line "rc.exe /d "_UNICODE" /d "UNICODE" /fo"Debug/AGain.res" ".\AGain.rc""
Output Window
Compiling...
cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
AGain.cpp
mp_sdk_audio.cpp
mp_sdk_common.cpp
Generating Code...
Compiling resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.7600.16385
Copyright (C) Microsoft Corporation. All rights reserved.
.\AGain.rc(10) : fatal error RC1015: cannot open include file 'winres.h'.
Results
Build log was saved at "file://c:\Program Files\se_sdk3\AGain\Debug\BuildLog.htm"
AGain - 1 error(s), 1 warning(s)
|
|
|
|
|
Hi,
Your source code seems to be compiling correctly according to your logs. Its the resource compiler that is failing. Your AGain.rc resource file is including a file named winres.h but the compiler cannot find it. You may be missing an #include path... locate this file and add the path into the projects 'Additional Include Directories'
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks!
I have the VC++ 2008 express edition, which I guess does not include the MFC library.
Perhaps winres.h is in this library, which I don't have.
Anyway, I renamed the winresrc.h file which is included in the Windows SDK, and I got the module to compile! So at least I'm getting somewhere.
|
|
|
|
|
|
See the link here[^] that David posted, it should help you.
|
|
|
|
|
Hi friends,
Thanks in advance.
I am using Acrobat Reader Browser document to show PDF file in my application.
But as I drag drop PDF file into internet explorer, it shows page count of PDF file.
How can I get page count in PDF file through C++/VC++.
Thanks,
Subhash Madhukar
|
|
|
|
|
you mean you are opening pdf document in internet explorer (or web browser control) and need to get the page count of opened PDF document?
--Cool_Dev--
|
|
|
|
|
Hi Cool_Dev,
thanks for reply.
I come to know IE use "Acrobat Browser document" ocx control to open pdf file.
I am using same ocx control but it doesn't expose any function to get open PDF page count.
BUT IE do the same.
I also come to know you can get page count by opening PDF in binary format and search for /Count or /Type /Page pattern.
I opened PDF in binary form using CFile and try to read single line and count " /Type /Page " pattern but as it is binary file, I could not able to read single line.
Line end is specified by '\n' or '\r' or '\r\n' i.e. 0x0A or 0x0D 0r 0x0D 0x0A.
To check the regular expression I used CAtlRegExp class.
If i check all these patterns and read single byte at a time, it takes lot of time. So can you please provide me some c++/VC++ code sample if possible to read the single line in PDF or get the page count.
Thanks,
Subhash Madhukar
|
|
|
|
|
I think Adobe Reader(AR) supports OLE Automation, so that another applications can embed AR with in them and automate it programatically. If IE automates AR to open pdf files, there will be two process running in task manager: iexplorer.exe (IE) & AcroRd32.exe (AR). This is not happening when I opened a pdf document in IE. That means IE uses an ActiveX control (Program Files\Common Files\Adobe\Acrobat\ActiveX\AcroPDF.dll) provided by Adobe. You can use this control in your MFC App by inserting "Adobe Reader" activeX control on dialog. You can generate wrapper class for this OCX, but i couldn't find any method to get no. of pages there.
Another way is to automate AR from you application. The Type Library for AR is Program Files\Adobe\Reader 9.0\Reader\AcroRd32.dll. Use OLEView.exe tool of Visual Studio to see the interfaces that AcroRd32.dll provides. There is CAcroPDDoc interface and it has a methods 'Open' to open a pdf document and 'GetNumPages(long*)' to get no. of pages Create wrapper classes for all necessary interfaces using "Add Class from Type Library" in visual studio, instantiate those classes in specified order, invoke methods on them, finally close the document and release the interfaces. Iam sure that this will work for you...
Every problem has n+1 solutions. 'n' is the number of solutions I have tried and '1' is that which is waiting to be tried.
--Cool_Dev--
|
|
|
|
|
Hi Cool_DeV
Thanks for reply,
I am already using first method i.e. to embed ocx control in my application.
I will give a try 2 second method, but i think it may change with diff. version of acrobat reader ?
Thanks,
Subhash
|
|
|
|
|
U r right. There may be changes in type libraries of different versions of acrobat reader. But if u build ur app with a lower version such as 7, that will run even if the installed version is higher one. The reverse my not be possible.
--Cool_Dev--
|
|
|
|