|
You can use a custom template. You just have to specify the CF_ENABLETEMPLATE flag.
CFontDialog cfd (&MyLogFont, CF_ENABLETEMPLATE |...);
cfd.m_cf.hInstance = AfxGetInstanceHandle();
cfd.m_cf.lpTemplateName = MAKEINTRESOURCE(IDD_MYFONTDIALOG);
When you create your template, just leave off the controls you don't want, and make sure you use the correct IDs for the controls you want to keep.
Control ID
Font Combo Box 1136
Font Style Combo Box 1137
Size Combo Box 1138
OK Button IDOK
Cancel Button IDCANCEL
Help Button 1038
Sample display box 1092
Comment box 1093
This might be an incomplete list, and the numbers might be defined in some header file somewhere, but this should get you going.
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
Hi,
I'm trying to create tool panels like the ones macromedia uses.
I tried it in 2 ways:
1) With CDialogBar derived classes.
This way they allways have the same focus as the parent frame (CMainFrame), but I can't catch
any WM_MOVING or WM_WINDOWPOSCHANGING messages. I need these to make them 'snap' to the borders.
2) With modeless dialogs.
Now I am able to make them snap to the borders, but they do not have the same focus as the main
frame.
Does anybody know how I can catch moving messages in the DialogBar or how to make sure that a modeless dialog has the same focus as its parent ?
would be very happy if someone could help me out cause I'm at the end of my knowledge.
thx
I used to have a life ... now I have a computer
|
|
|
|
|
I have a mainframe function that I want to run from a view. how do I do this? How to get a pointer to the mainframe? What it will do is switch to view2 from view1 when i call it from view1.
Can I do AfxGetMAinWnd->SwitchView from class view1?
Thanks,
ns
|
|
|
|
|
Actually,
I tried
void CFormViewMDIView::OnButton1()
{
CRuntimeClass* pViewClass = RUNTIME_CLASS( CForm2View );
if ( pViewClass == NULL ) return;
CMultiDocTemplate* pTemplate = theApp.m_pView2Template;
if ( pTemplate == NULL ) return;
AfxGetMainWnd->SwitchView( pTemplate, pViewClass );
}
and it doesnt like AfxGetMainWnd->SwitchView( pTemplate, pViewClass );
Error is:
C:\Trainer\FormViewMDISwitch\FormViewMDIView.cpp(157) : error C2227: left of '->SwitchView' must point to class/struct/union
SwitchView is a mainframe function.Helllpp
|
|
|
|
|
Yes... but it's :
AfxGetMainWnd()->SwitchView(...)
You've omitted "()" after AfxGetMainWnd... I think...
Hello World!!!
from Raphaël
|
|
|
|
|
I only have two views in my project. I need to send a user defined message from view2 to view1. How do I get the pointer to view1 which I need in doing pView1->SendMessage (..) from view2 ( If I've understood the senddmessage correctly). Is the view currently on top in the mdiframe the active view? In that case I'm sending a message from my active view (view2) to view1 which isnt active, and understand that I need a pointer to the view the message is going to.
A side question:
Is it possible to send a message from the doc to an inactive view that will make it active? Does it make sense to send a message to an inactive view? Is it legal?
another question. Lets say I have a SwitchView function that lets me switch from one view to another. Now if In my active view i say
SwitchView;
dosomethingelse;
will dosomethingelse get executed? Or is anything after switchview ignored because the view is not active anymore..?
Thanks
ns
|
|
|
|
|
ns wrote:
will dosomethingelse get executed?
Yup! I don't think that code execution in the view will be impacted in any way by the activity state of the associated view window object.
ns wrote:
Is it possible to send a message from the doc to an inactive view that will make it active? Does it make sense to send a message to an inactive view? Is it legal?
Yup again, IMHO. (The sense of course depends on your goal an your application). As you can send messages to inactive windows (I think the "activity" of a window is only important regarding keybord input) via API you can send them to inactive views using MFC as well!
ns wrote:
I only have two views in my project....[snip]
You could get a pointer to the doc object from one view, and then enumerate all the documents views and call SendMessage on them.
Cheers
HTH
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
Hi...
If I want to use methods of CMyView via CMyDoc, I must to have a pointer to CMyView!!! How??? And is this logic to do that (does anybody do it)???
Is this a clean solution :
CMyView* pView = (CMyView*)m_viewList.GetHead();
Thanks
Hello World!!!
from Raphaël
|
|
|
|
|
|
Hello @all!
I have got a CListBox and added a horizontal scroll bar.
Now my question: How can I get the lenght of my ListBox?
The lenght of my string can I get through:
m_ctrlListBox.GetTextLen(0);
Correctly?
Lucky2002
|
|
|
|
|
m_ctrlListBox.GetCount() will return an int for the number of items in the control or LB_ERR if an error occurs.
|
|
|
|
|
I´m sorry, my mistake:
I want to know the width of my ListBox.
Lucky2002
|
|
|
|
|
Ah! Okay, I'm not sure if I know what you're asking but...
Use m_ctrlListBox.GetHorizontalExtent() to get the scrollable width of the list box, in pixels.
If you just want to know the screensize of the ListBox, use...
CRect rect;<br />
m_ctrlListBox.GetClientRect(&rect);<br />
rect.DeflateRect(CSize(GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)));<br />
iWidth = rect.Width();
|
|
|
|
|
Hi!
Thank you very much! I needed the last one.
Now I have another question and hope you can help me:
I need the lenght of the strings in the ListBox. When I use
m_ctrlListBox.GetTextLenght(0)
I only get the number of variables without the blanks between the words.
Thank you!
Lucky2002
|
|
|
|
|
Call CDC::GetTextExtent() on each string as you add them to your list control, and keep the width of the widest string as the width of your listbox.
int width = 0;
CSize size (0, 0);
CDC *pDC = m_listbox.GetDC();
int saved = pDC->SaveDC();
pDC->SelectObject(GetFont());
while (ThereIsAStringToAdd)
{
m_listbox.AddString(TheStringToAdd);
size = pDC->GetTextExtent(TheStringToAdd);
width = width > size.cx ? width : size.cx;
}
pDC->RestoreDC(saved);
ReleaseDC(pDC);
m_listbox.SetHorizontalExtent(width + 5);
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
Works great!!!!
Thank you very very much ....
|
|
|
|
|
I'm working on a Dialog-based project. The app, as usual, starts my dialog class with DoModal(). However, I sometimes want the dialog to start hidden, depending on calculations done in OnInitDialog(). I know how to use ShowWindow() but where do I control whether the dialog will *start* visible or hidden?
|
|
|
|
|
Mike Dunn's C++ FAQ, §7.6, shows how to have a dialog hidden at start-up. I guess you can adapt the technique to your needs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you. I just tried it and that solution was very easy to adapt successfully. I guess I should have checked the FAQs first.
|
|
|
|
|
Ok this is a simple question.
Can you have all DialogBoxes, TextBoxes, resources etc in DLL, and then have .exe file call some kind of initialisation function contained in DLL that would start whatever application is supposed to do.
Are there any problems with this. I haven't tried implementing myself.
[thinkig in terms of Win32 API]
Regards,
Venet.
--------
Black holes are where God divided by zero.(Steven Wright)
|
|
|
|
|
No problem, but you have to be careful when loading resources, because you need the instance handle; and a simple call to GetModuleHandle(NULL) will not give it to you (it will return the calling exe), so you need to get it in the DllMain function and use for all resource loading tasks.
I can´t see more problems actually...
"nobody knows it, but you´ve got a secret smile, and you use it only for me"
|
|
|
|
|
Thanks
Regards,
Venet.
--------
Black holes are where God divided by zero.(Steven Wright)
|
|
|
|
|
Its dumb question.
I have VS.Net.What/Where is my C compiler file?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
|
Thank you Nish.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|