Solved

void CCalendar::SetDayFont(LPDISPATCH newValue)

Posted on 2000-04-18
16
788 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 47
How to know only "File created" with EventLog 3 35
VBA "SendKeys" Syntax for Multiple Keystrokes 7 126
haveThree challenge 22 123
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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