|
koumodaki wrote: The CreateInstance() call fails...
And the value of hr would be what?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
On my PC hr = -2147221008 while debugging......guess its some junk value
|
|
|
|
|
It appears you have failed to call CoInitialize() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks David. I had not called CoInitialize(). It works now.
|
|
|
|
|
You have guessed wrong. Use the Error Lookup tool to get the description of that error.
|
|
|
|
|
Michael Dunn wrote: You have guessed wrong.
Well that hardly ever happens.
|
|
|
|
|
Try
HRESULT hr = m_pXmlDoc.CreateInstance( __uuidof(MSXML2::DOMDocument40));
This way, you ask explicitly for a DOM document version 4.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
I get an error while compiling.
error C2039: 'DOMDocument40' : is not a member of 'MSXML2'
error C2065: 'DOMDocument40' : undeclared identifier
Could you please tell me th eproper file to include?
|
|
|
|
|
*I* do
#import "../thirdparty/msxmlbase/msxmlinclude/msxml2.tlb" named_guids but the path will be totally different for you.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
I'm building an SDI app in VC++6. From Document, user can click on a button which opens a Dialog. Dialog has a CComboBox. The values of the CComboBox are populated from a dynamic array (~200 items) stored in the Document.
I figured out how to populate the CComboBox with static values using AddString in the InitDialog method of the Dialog.
BOOL CMslDatabase::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
m_msl_list.AddString("ICBM");<br />
m_msl_list.AddString("SRBM");<br />
return TRUE;<br />
}
Here's my problem. How do I pass the array to the Dialog so I can use AddString to populate the ComboBox with ~200 dynamic values?
|
|
|
|
|
penny black wrote: Here's my problem. How do I pass the array to the Dialog
You can do it when constructing the CMslDatabase object, or after by calling a CMslDatabase method. If you opt for the latter, be sure and do it before calling DoModal() .
penny black wrote: m_msl_list.AddString("ICBM");
Missles, eh?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
from where you call the dialog, something like (pseudo c++ code):
...
CMslDatabase dlg;
dlg.SetArray( m_YourArray );
dlg.DoModal();
...
class CMslDatabase
{
void SetArray ( std::vector& v ){ m_vector = v;};
std::vector< std::string > m_vector;
};
BOOL CMslDatabase::OnInitDialog()
{
CDialog::OnInitDialog();
std::vector< std::string >::iterator it = m_vector.begin();
while ( it != m_vector.end()
{
std::string aString = *it;
m_msl_list.AddString( aString.c_str() );
++it;
}
return TRUE;
}
|
|
|
|
|
Either have your document fill the dialog between object creation and dialog Display,
CMyDialogWithComboBox dlg;
dlg.m_Array = Array; or hand the dialog in its constructor a pointer to your document, and fill in OnInitDialog()
BOOL CMslDatabase::OnInitDialog()
{
if( !m_pDoc) {
return;
}
CDialog::OnInitDialog();
m_msl_list.AddString( m_pDoc->m_List[0]);
m_msl_list.AddString( m_pDoc->m_List[1]);
return TRUE;
}
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Thanks for all the quick responses. Simpler than I was trying to make it.
Working on a "video game"
|
|
|
|
|
I'll give you a complex answer if it will *help* ?
But as you've been shown, there are fewer ways of skinning a cat than passing parameters.
For an array that could be large, I'd favour passing a pointer to the array, or to the doc containing the array.
If the array can be large, then you'll also want to look at CWnd::SetRedraw on the combobox so it doesn't fill slowly and visibly.
Iain.
|
|
|
|
|
I am trying to create a System Wide hook to listen to Window Creation events in the system .
For this purpose , I set up a new Project - > an regular MFC DLL
I have created SHARED regions where I Store the hook id created , the module and the HOOKPROC values .
The problem is that I am still not able to intercept any Window Creation Events .
Clearly am missing something
Help is appreciated.
Below is the main code of my DLL
<br />
<br />
#include "stdafx.h"<br />
#include "HookEg.h"<br />
#include "HookCommon.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
<br />
<br />
<br />
#pragma data_seg(".SHARED")<br />
<br />
HHOOK hookid = 0;
HINSTANCE mod =NULL;
HOOKPROC proc =NULL;
<br />
#pragma data_seg()<br />
#pragma comment(linker, "/section:.SHARED,rws")<br />
<br />
<br />
static LRESULT CALLBACK ShellProc(int nCode,WPARAM wParam,LPARAM lParam)<br />
{ <br />
TRACE("Shell message rcvd nCode = %d wParam = %d lParam=%d \n",nCode,wParam,lParam);<br />
if(nCode == HSHELL_WINDOWCREATED )<br />
{<br />
TRACE("new window created \n");<br />
<br />
}<br />
else if(nCode == HSHELL_WINDOWDESTROYED)<br />
{ <br />
<br />
}<br />
<br />
return CallNextHookEx(hookid, nCode, wParam, lParam); <br />
}<br />
<br />
<br />
<br />
<br />
BEGIN_MESSAGE_MAP(CHookEgApp, CWinApp)<br />
END_MESSAGE_MAP()<br />
<br />
<br />
CHookEgApp::CHookEgApp()<br />
{<br />
}<br />
<br />
<br />
CHookEgApp theApp;<br />
<br />
BOOL CHookEgApp::InitInstance() <br />
{<br />
<br />
<br />
return CWinApp::InitInstance();<br />
}<br />
<br />
int CHookEgApp::ExitInstance() <br />
{<br />
if(hookid)<br />
{<br />
if(UnhookWindowsHookEx(hookid))<br />
hookid = 0; <br />
else<br />
TRACE("Error = %d\n",GetLastError());<br />
}<br />
<br />
return CWinApp::ExitInstance();<br />
}<br />
<br />
<br />
HOOKEG_API void HookegInit() <br />
{<br />
<br />
hookid = 0;<br />
<br />
mod = GetModuleHandle("HookEg.dll");<br />
<br />
proc = ShellProc;<br />
<br />
hookid = SetWindowsHookEx(WH_SHELL , proc , mod , NULL);<br />
<br />
<br />
}<br />
<br />
|
|
|
|
|
Try using WH_CBT instead of WH_SHELL, and watch for the HCBT_CREATEWND code.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
I didnt realize
1. You cannot debug a Hook or expect TRACE statements in the IDE while debugging
2. I was adding the Hook creation in the InitInstance method so even though my app exited the Hook was alive !!!
Just learnt these the HARD way !
Engineering is the effort !
|
|
|
|
|
Using the Dialog Editor, I've started a new Dialog Box.
(The OK/CANCEL buttons were placed on the form by the Editor.)
Then I added a picture control, stuck the BMP into the resources, gave the BMP a name, and finally set the picture control to use the BMP. I also stretched the form to give the picture enough room.
The picture has nothing going on in the south-east and south-west corners, so I would like the OK and CANCEL buttons to be located in those corners.
However, the picture covers the OK and CANCEL buttons... I would like the picture to be under the buttons.
When the (MFC) project is built and executed, running the mouse over the picture where it's covering the buttons will make the buttons redraw ontop of the picture - but this behavior is not not a useful design.
Is there any way to change the Z-order of the buttons and picture control ?
(In Visual Basic it's as easy as "Send to Back" when right-clicking on a control)
|
|
|
|
|
You should be able to change the order of the controls in the dialog resource.
You can use Format/Tab Order or do it by hand in the .rc file.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I exited VS8, edited the .rc so that the picturebox is listed after the buttons, reloaded the project and all is well thanks !
(note: when I left or right-click either button, the Dialog Editor always selects the picturebox under the button. This seems like a bug in the Dialog Editor)
|
|
|
|
|
abiemann wrote: so that the picturebox is listed after the buttons
Didn't you want it before ("under") the buttons?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
indeed, I got it mixed up. This is what it looks like in the .rc:
BEGIN
CONTROL 130,IDC_STATIC,"Static",SS_BITMAP,1,1,446,345
DEFPUSHBUTTON "PASS",IDOK,2,332,50,14
PUSHBUTTON "FAIL",IDCANCEL,397,332,50,14,BS_TOP
END
now I just wish that the Dialog Editor would select one of the buttons when I left/right-click them (instead of the picture). To select either button I need to Tab through.
|
|
|
|
|
abiemann wrote: now I just wish that the Dialog Editor would select one of the buttons when I left/right-click them (instead of the picture). To select either button I need to Tab through.
I see what you mean That's pretty annoying!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
abiemann wrote: now I just wish that the Dialog Editor would select one of the buttons when I left/right-click them (instead of the picture). To select either button I need to Tab through.
I'm going to submit this to MS. Should be easy enough for them to hittest from
the "top-down" (reverse tab order) instead of tab order...right?
Because that's just silly
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|