|
I am having some trouble with something that is probably very simple. I have a COM project (exe) and it does not use any ATL. It is fairly simple, a dialog box opens with 2 buttons, the first is to run MS Word. When pressed, word opens up and the user can enter some text. After a lot of research and trial-and-error, I was able to put a button on the Word toolbar. But I do not know how to know when the button has been pressed. This is my class:
/*----------------------------------------------------------------------------*/
const IID IID_IWordAppEventSink = __uuidof(Word::ApplicationEvents);
const IID IID_IWordDocEventSink = __uuidof(Word::DocumentEvents);
const IID IID_ISpecialSaveExit = __uuidof(Office::CommandBarButton);
/*----------------------------------------------------------------------------*/
class CWordEventSink : public CCmdTarget
{
DECLARE_DYNCREATE(CWordEventSink)
public:
CWordEventSink();
virtual ~CWordEventSink();
BOOL Advise(IUnknown* pSource, REFIID iid);
BOOL Unadvise(REFIID iid);
void SetLauncher(CTestDlg* pWordLauncher);
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWordEventSink)
public:
virtual void OnFinalRelease();
//}}AFX_VIRTUAL
protected:
// Generated message map functions
//{{AFX_MSG(CWordEventSink)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
// Generated OLE dispatch map functions
//{{AFX_DISPATCH(CWordEventSink)
afx_msg void OnAppStartup();
afx_msg void OnAppQuit();
afx_msg void OnAppDocumentChange();
afx_msg void OnDocNew();
afx_msg void OnDocOpen();
afx_msg void OnDocClose();
afx_msg void PSISaveAndExit();
//}}AFX_DISPATCH
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
private:
CConnectionAdvisor m_AppEventsAdvisor;
CConnectionAdvisor m_DocEventsAdvisor;
CConnectionAdvisor m_BarEventsAdvisor;
CTestDlg* m_pWordLauncher;
};
I kind of cheated by using an example article written by Christian Staffe called Automating and Eventing in Word. But it never mentioned what to do to capture when the button has been pressed. Does anyone have any thoughts or suggestions? Examples would be great to, I am still trying to learn all this COM stuff..........
|
|
|
|
|
Hello,
I've a document class with an array of records each containing about 15 fields. Currently, I send messages to my GUI to update a record (listview) if that record's fields have been changed (intercepted at documents 'setrecordfield()' function). The problem is that the user can change as many as 5 fields in one GUI operation. This causes my current design to send 5 messages to the GUI to refresh the display--this can become very slow with an increasing number of records/changes (plus, some of my display text items require relatively long functions to compute for each update).
I've put some thought in to this but haven't come up with an eloquent design that would only update the GUI when it 'should' (i.e., after the document has stopped changing but not too long after so that the user witnesses delay). I could litter my code with conditional update calls, but that seems like a lot of 'ifs' and would require that I keep changing these places throughout development. I'm not a professional MFC developer, so any hints or approches would be appreciated.
Thanks!
JennyP
|
|
|
|
|
Maybe you can take advantage of LockWindowUpdate just like this:
CYourView:SomeCommandHandler()
{
AfxGetMainWnd()->LockWindowUpdate();
AfxGetMainWnd()->UnlockWindowUpdate();
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the response.
In my case, its not the graphical device painting that takes time, it's the GUI class calculations that I employ each time the data changes. Unfortunately, the data will change 5 times "at once" causing these calculations to be run 5 times when all I need is one calculation to be done on the last data-change (only after the "last" data change).
Thanks!
JennyP
|
|
|
|
|
Well, you can develop a similar custom-made mechanism that tells the "GUI class" not to initiate calculations when in the middle of a sequence of record changes. Don't know how hard this would be to accomplish in your particular case.
Another altenative is to have GetData and SetData methods for your doc class that allows you to perform the changes on a local copy of the data. When done, these changes can be plugged again into the document class, thus triggering the GUI updating.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am looking for an MFC Grid. The latest MFC Grid 2.24 looks good but, alas, I am still stuck with MSDEV 6 (no .NET at this point).
I would like to check out MFC Grid 2.23 which I believe is still configured for MSDEV6. If anyone knows where I could download 2.23 or could email it to me, I would be eternally gratefull.
Thanks
beamsack
|
|
|
|
|
I'd say v2.24 still works in VC++ 6.0, it is only it's been upgraded to work for VC++ .NET also.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the reply Joaquin,
I tried to build the project and lack the MFC dlls for MSVC 7.
My project is MSVC 7 adverse right now so even if I could scare up the DLLs for evaluation - I would never be able to distribute my app. I had hoped that the platform SDK would have had the latests MFC dlls not this was not to be.
beamsack
|
|
|
|
|
Well, I'd say that, although the demo project works only for .NET, the library itself should be compatible with VC++ 6.0.
Nevertheless... (don't tell anybody ) Chris was smart (or careless?) enough as to leave this trace in the site:
http://www.codeproject.com/miscctrl/gridctrl/gridctrl_demo223.zip[^]
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquin,
Thanks a million.
I think I will follow your suggestion and try to build 2.24 with 6.
The problem I had described was at run-time not build time.
Time for some fun
beamsack
|
|
|
|
|
Hi there,
I wrote this code for changing windows background color, it works fine in Win98 but it doesn't wrok on WinXP and Win2000 !
HBRUSH CSearchDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch(nCtlColor)
{
case CTLCOLOR_DLG:
{
CBrush brush(RGB(0, 30, 104));
pDC->SelectObject(brush);
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)brush.GetSafeHandle();
}
case CTLCOLOR_STATIC:
{
}
case CTLCOLOR_EDIT:
{
}
}
return hbr;
}
What's wrong ???
Please help me !
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
{
CBrush brush(RGB(0, 30, 104));
pDC->SelectObject(brush);
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)brush.GetSafeHandle();
} Since brush is defined in the local scope, it gets destroyed as soon as the function exists. I'd say it's merely a matter of luck that this works in Win98. Instead, make brush a member variable of CSearchDialog and initialize it only once (for instance, in the constructor for the dialog).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello dear López
Ans thanks alot for your helps, now it works fine
Best Regards,
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hello dear López
Just call me Joaquín (or Joaq, as Nish prefers to put it)
Ans thanks alot for your helps, now it works fine
Glad to be helpful.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi!
I know that this is not the first time this question is asked, but I don´t found a solution yet so I hope someone in here is able to help me.
Problem is: With the standart MFC functions I can´t get the refresh rate of the display device under Win9x (Win98 and ME is important), neighter the current, nor all avaible.
Under WinNT and above all is fine. EnumDisplaySetting or GetDeviceCaps in "Normal" Mode or the equals in DirectX Mode returns all Values correct, but under Win9x only a Zero or 1 comes back.
Question: How can I get the value? Anybody knows other ways? I know it is possible (look at MultiRes or QuickRes but these are not OpenSource ).
Bye FatBastard
|
|
|
|
|
Hello there,
Is there any tutorial and class for loading animated gif ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
when you come to the CP main page, there is a list of categories down the left side of the page. one of those categories is "Bitmaps and Palettes". if you click that, you'll find many different classes that will do this.
-c
"Kate said / The flowers of intolerance and hatred / Are blooimg kind of early this year / Someone's been watering them.
-- Robyn Hitchcock, Devil's Radio
|
|
|
|
|
Hi,
I have many combo boxes my my dialog based application. I want to a combobox to loose focus, when the user clicks outside the combobox. The user should be able to click anywhere in the dialog (not necessarily on another control.) and the combobox should loose focus.
Please help me in this regard.
Arthi
|
|
|
|
|
try handling WM_LBUTTONDOWN in the parent dialog class and calling SetFocus() on the dialog.
if SetFocus() doesn't work (dialogs can be a bit funny) then try sending WM_KILLFOCUS to the control with the focus.
|
|
|
|
|
Hi all,
I need to get notification when the network link up or down.
is there any way to do it?
did any one know how the windows system know this and display a message at the coner of the screen when link up or down?
Thanks a lot.
|
|
|
|
|
May be that's a dumb answer from me, but you can show a blinking systray icon for the network link just by checking a box in the Network settings.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site. Support for development will ship at the same time as the Windows XP Service Pack 1 (SP1) release.
|
|
|
|
|
Hi ano,
take a look at the System Event Notification Service (SENS), and especially
the ISensNetwork interface. I believe there is an article about this in a recent Dr. Dobbs, or search the Microsoft site.
Bye,
Alwin
|
|
|
|
|
Hi Alwin,
I've read the SENS article. it works fine with dialup line. but augly with LAN. it seems the desktop network connection link up/down message is not from SENS
Did you know other info?
Thanks.
|
|
|
|
|
Hi,
It turned out that I did not read the article in Dr. Dobbs but in MSDN, which
is available electronically here.
The article indicates that SENS does not work well for what you want to do but describes an alternative using WMI (Windows Management Instrumentation) that might help you.
Regards,
Alwin
|
|
|
|
|
I want to ask like this below example?
Example :
If there are 3 people , all of them have text file name “1.txt”.
If Mr. A has data X in text file like this
X = POIR
Mr. B has data X in text file like this
X = JUKFDSSA
Mr. C has data X in text file like this
X = OYTGF
I want to embed this data in program while compile.
Example: If I use text file of Mr.A I will have data X = POIR after compile program. If I use text file of Mr.B I will have data X = JUKFDSSA after compileprogram.
If my program is in directory C:\ .
Where I need to put “1.txt” file and how to write program to do that .
Thank you.
|
|
|
|