Solved

void CCalendar::SetDayFont(LPDISPATCH newValue)

Posted on 2000-04-18
16
772 Views
Last Modified: 2013-11-20
Hi again,
In order for me to understand the use of LPDISPATCH, let's look at the Calendar control.

I've declared:

CCalendar m_calCtrl;
COleFont m_font;

I've got a dialog application and I've inserted the Calendar control. I want the user to change the "Day Font" at run time, let's say setting the font to "italic" (m_font.SetItalic(TRUE)). For this I need to set the properties of the m_font, and then call the function

void CCalendar::SetDayFont(LPDISPATCH newValue)
{
      static BYTE parms[] =
            VTS_DISPATCH;
      InvokeHelper(0x1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
             newValue);
}

My problem is that I do not know how to pass in for the newValue.
I've tried many things, but still with no luck. Thanks
0
Comment
Question by:Malek103197
  • 7
  • 7
  • 2
16 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 2728839
COleFont is derived from COleDispatchDriver, which has a member variable m_lpDispatch.

m_calCtrl.SetDayFont(m_font.m_lpDispatch);
0
 

Author Comment

by:Malek103197
ID: 2729371
I've tried this already and I get a small message box popping up with a red circle, whitX and an OK button. I press the OK button and the program continues without error.

My code is:

m_font.SetItalic(TRUE);
m_calCtrl.SetDayFont(m_font.m_lpDispatch);

I also tried a m_calCtrl.Refresh();
0
 
LVL 1

Expert Comment

by:MT_MU
ID: 2729448
This should do it for you....

COleFont olefont = m_Calendar.GetDayFont(); // Retrieve the original info...

CString old_name = olefont.GetName();

olefont.SetName("Courier");
m_Calendar.SetDayFont(olefont);
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 23

Expert Comment

by:chensu
ID: 2729461
I think you need to create the font instead of calling SetItalic only. What MT_MU suggests is one of the methods.
0
 
LVL 1

Expert Comment

by:MT_MU
ID: 2729472
It should be very similiar for the Italic (sorry I overlooked that)...

COleFont olefont = m_Calendar.GetDayFont(); // Retrieve the original info...

olefont.SetItalic(TRUE);
m_Calendar.SetDayFont(olefont);
0
 

Author Comment

by:Malek103197
ID: 2732783
Adjusted points from 100 to 300
0
 

Author Comment

by:Malek103197
ID: 2732784
Thanks, the following works:

COleFont olefont = m_calCtrl.GetDayFont();
olefont.SetItalic(TRUE);
m_calCtrl.SetDayFont(olefont);

The following also works:

COleFont olefont(m_calCtrl.GetDayFont());
olefont.SetItalic(TRUE);
m_calCtrl.SetDayFont(olefont);

The trick is to find another ActiveX property function that returns a COleFont class. Now I wish to extend this to get the TreeView ActiveX control working, which from my observation, is not that easy. I realize that it would be much simpler to use the CTreeCtrl class, but my reason for pursuing this is in order to use a commercial "GIS Mapping" ActiveX control in my application.

So far, on the TreeView control I've determined that the CTreeView1 has a property which sets the ImageList:
m_treeCtrl.SetImageList(LPDISPATCH newvalue);

So now I have to find a property function that returns an ImageList. But, the only other COleDispatchDriver that comes with the CTreeView1 control is the CPicture. So, I think I must use the CPicture class to load some icons or bitmaps, and then some how add these to an image list, and then set the image list of the m_treeCtrl. I've added the ImageList ActiveX control in order to assist, but now I'm confused on how to proceed.

I beleive this is related:

CPictureHolder pic;
pic.CreateFromIcon(IDI_ICON1);
pic.CreateFromIcon(IDI_ICON2);
CPicture picture(pic.GetPictureDispatch());

I also beleive it is related to CListImage1, CImage & CImages, and also the CPicture.

Since I've found people that have experience using ActiveX controls wiht VC++, I'd like to continue since I've been unable to find much documentation on this subject. Please help, thanks.

0
 
LVL 1

Expert Comment

by:MT_MU
ID: 2732822
Okay - but since this question has been answered - you need to go ahead and award the points.  Ask the next question, and I'm sure you will find as much help for it.
0
 
LVL 1

Expert Comment

by:MT_MU
ID: 2732831
Actually the next question is almost trival.

With a TreeView - you simply need to add the following code...

CFont* pFont = m_Tree.GetFont(); // get the current font
LOGFONT logfont;
pFont->GetLogFont(&logfont);  // and it's characteristics - for me this returns lfHeight = -11;

logfont.lfHeight = -14;  // set a new height

m_NewFont = new CFont;  // create a new font
m_NewFont->CreateFontIndirect(&logfont); // with the appro characteristics
m_Tree.SetFont(m_NewFont); // and tell the list control to use it

I'm naturally assuming that m_Tree is a variable holding the CTreeCtrl, and that the above code will be in OnInitDialog()

One warning - m_NewFont needs to be a member variable - and needs to be deleted when the dialog exits.




0
 

Author Comment

by:Malek103197
ID: 2732978
For MT_MU:

OK, I've rejected Chensu's answer and will accept yours.

I'm not interested in setting the Font properties of the TreeView; I agree, it is a straight forward process. My question is about setting the Iamgelist for the TreeView.
0
 

Author Comment

by:Malek103197
ID: 2732982
Oh yes, just a remenider, that I am working with the TreeView ActiveX control, and not the CTreeCtrl class.
0
 
LVL 1

Expert Comment

by:MT_MU
ID: 2732983
Post the question - and I'm sure you will get lots of good answers.
0
 
LVL 1

Accepted Solution

by:
MT_MU earned 300 total points
ID: 2733083
For Malek to accept
0
 

Author Comment

by:Malek103197
ID: 2733112
Hi MT_MU,

Can you assist me on the TreeView ActiveX, I really need to get this stuff in order to work with my GIS Mapping ActiveX. Thanks.
0
 
LVL 1

Expert Comment

by:MT_MU
ID: 2733118
I'll give it my best shot.  FWIW, you can accept comments as an answer.
0
 

Author Comment

by:Malek103197
ID: 2734783
OK, looking forward to your assistance.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 93
no14 challenge 14 66
Window placement 17 80
Line meaning 9 85
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now