|
are you sure you included the correct lib file in the libraries part of linker settings?
|
|
|
|
|
I've just started writing custom control after reading excellent article on this site.
http://www.codeproject.com/miscctrl/customcontrol.asp
New class mostly looks like what in that article. But in OnPaint(), I want to get current font being set to that control and print text with it, so I do this;
void CLogViewCtrl::OnPaint()
{
CPaintDC dc(this);
RECT rect;
CFont *pOldFont;
CFont *pFont = GetFont();
GetClientRect(&rect);
pOldFont = dc.SelectObject(pFont);
dc.SetTextColor(RGB(0,0,0));
dc.SetBkMode(TRANSPARENT);
dc.TextOut(0,0,"Code Project is great!");
dc.SelectObject(pOldFont);
}
Then, I can do this like;
m_LogWindow.SubclassDlgItem(IDC_LOGWINDOW,this);
m_LogWindow.SetFont(&m_FixedFont,0);
I did that in OnInitDialog() of parent Window but, font was not changed. Trust me m_FixedFont is OK and same method is working for normal controls. I added
m_LogWindow.GetFont();
right after that .SetFont() line, but return font handle was NULL. Why??? I'm sure sending right font handle to that CWnd derived control by WM_SETFONT but it will return NULL with WM_GETFONT! I'm very confused.
Do I need to add special handling code for that? Simple CWnd window won't keep font handle? When I look at CEdit's source code, there is no code for Set/Get font handlings. Can anyone help me?
(Please don't tell me adding CFont data member to my class.)
reiko
|
|
|
|
|
Do I need to add special handling code for that? Simple CWnd window won't keep font handle? When I look at CEdit's source code, there is no code for Set/Get font handlings.
Yes, you have to handle WM_GETFONT/WM_SETFONT yourself. Win32 controls are doing this for you. If you derive from plain CWnd, there's no such functionality in place.
In the Platform SDK docs, at "UI Services/Windows User Interface/Controls" you'll find the topics describing the default message processing done by controls. In the combobox section, for example, you'll find that combo "saves the specified font handle in an internal structure" during the WM_SETFONT processing.
When I look at CEdit's source code, there is no code for Set/Get font handlings.
This code lives outside the MFC - the Win32 edit control handles the message.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Now I understand what I should do.
I wonder how many people have this question trying to write custom control from scratch.
Thanks.
reiko
|
|
|
|
|
how can i set a defaule value for ActiveX control's method
|
|
|
|
|
Question is not clear. What do you mean by value of a method? Is it about default arguments?
|
|
|
|
|
How to find the users that logged on one domain?
sandos
|
|
|
|
|
Hi
iam using a picture control for showing bitmaps and gif files .but if the picture is big then i wanna show it in scolling manner without resizing my control.
is there any other way(or any other controls) which i can show bmp/gif with scrolling enabled
thanx in advance
buddie
Software Engineer
|
|
|
|
|
What type of app are you bulding? Is it dialog based or SDI/MDI, or don't you use MFC at all?
(2b || !2b)
|
|
|
|
|
Have a look at Microsoft article Q218972. The IPicture interface works fine for me. You would also be able to support JPEG files if you used it.
Hope this helps.
Steve.
|
|
|
|
|
I have an SDI app with static SplitterWnd with two panes. If I load a CFormView in both of them everything works fine. But if I load a CFrameWnd into one of the panes I get an Assertion Error (I think it's either CMainFrame::AssertValid() or CFrameWnd::AssertValid() ) when exiting the app. What am I doing wrong? Do I have to add any member functions to my CFrameWnd class? I've been trying to solve that problem for two days and I'm desperate. Please help me!
btw: In Release mode everything works alright.
Semlo
|
|
|
|
|
Doesn't anyone have a hint for me?
Do you need more detailed information?
please someone help me!
Semlo
|
|
|
|
|
Where do you get the assert? The call stack should show after the break.
Basically, I don't think you can put a CFrameWnd inside a splitter - I think CSplitterWnd expect its children to be CView derivatives. Don't ask me why! If you want to make a convoluted UI with views and splitters inside other views and splitters I suggest you use Zoran Todorovic's Visual Framework (http://www.codeguru.com/advancedui/VisualFx.shtml).
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Thanks a lot for your answer, Steen!
This really helps me a lot! You guessed right, I want to create a nested splitter. It should look like this:
------------------------------
|*CForm* |***************|
|*View** |***************|
|***1***|***************|
|---------|*****CView***** |
|*CForm* |***************|
|*View** |***************|
|***2***|***************|
-------------------------------
As i have been thinking about putting tabs in "CFormView 2" pane Zoran Todorovic's Visual Framework probably is the perfect solution for me. Thanks for the hint!
Anyway, if someone knows an easier (shorter) way of creating nested splitter please let me know!
Semlo
|
|
|
|
|
How can I do this. Does someone know of a class already created...
thanks
Ralph Krausse
|
|
|
|
|
You'll need to load a bitmap, draw text onto it and save it. The first and third can be done by a class that was added last week, and the middle is easy - CDC::TextOut
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Can you give me the name of those classes?
'
thanks
r-
|
|
|
|
|
CXImage. I didn't look it up the first time because it's just in the section on bitmaps, where you'd expect it to be.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
|
I'm an amateur programmer, and don't know that much about C++ and MFC. I was wonder just what exactly is MFC? What does it provide for or do for the programmer? What is it used for? Is it used for Win32 programming, or just in general? If it's used in Win32 programming, does it make the programmer's life easier? I would appreciate it if someone would try to answer all of my questions to the best of their knowledge. Thanks.
~dreadknought
|
|
|
|
|
The Microsoft Foundation Classes are a set of classes that encapsulate and extend Win32, which has the net effect of making development more object oriented. For example, in Win32, you called functions to create a device context, stored the handle and then deleted it. MFC wraps those calls into a class called CDC. This is especially helpful if you have Visual Assist, because you create an object, add a dot operator and get a list of available methods, which sure beats looking through MSDN for a function you know exists but can't remember the syntax for. It is also safer because destructors can ensure an item is cleaned up, which is not the case in Win32 unless you write your own class. There are all sorts of additional classes such as CArray ( rubbish, you should use vector ) and CString ( much more useful than std::string ), right through to more complex classes that manage all sorts of things.
Your copy of VC should have come with a wall chart that maps the relationships between all the MFC classes. You'll find the majority of the code on this site uses MFC. VC wizards build all the boiler plate MFC code for you, so for example to create a window or dialog takes more work in Win32, not least because the compiler isn't writing the basic stuff for you.
That's a simplistic explanation but I hope it gives an overview.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Hello, the codegurus around the world.
1) What exactly is MFC?
I used to read some comment of Bill Gates about MFC.
MFC is the creation which the genius programmers of Microsoft made.
MFC consists of the basic three classes like CObject, CWnd, and the other
class not derived from CObject and CWnd, and some classes are derived from
CObject and CWnd.
However, if we read the source code of these classes, we notice that MFC is wrapped by the Widnows API.
2) What does it provide for or do for the programmer?
If we made some GUI application, we at once understand that MFC makes us save the code lines and maintain the code easily.
Basically, Window 32 programming and MFC relation are almost same as C and C++. However, if we make some advanced programming like Network, Window hook,
and the other, we need both MFC and Windows API.
MFC is a powerful class for GUI application, but we also need the knowledge
of Windows API.
Good luck.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
MFC consists of the basic three classes like CObject, CWnd, and the other
class not derived from CObject and CWnd, and some classes are derived from
CObject and CWnd.
However, if we read the source code of these classes, we notice that MFC is wrapped by the Widnows API.
Actually CWnd is derived from CCmdTarget, which is derived from CObject. So the majority of MFC classes derive from CObject, but there is a reasonable size group that does not. Serialisation is one reason to derive your own classes from CObject.
2) What does it provide for or do for the programmer?
If we made some GUI application, we at once understand that MFC makes us save the code lines and maintain the code easily.
Agreed - couldn't have said it better ;0)
Basically, Window 32 programming and MFC relation are almost same as C and C++. However, if we make some advanced programming like Network, Window hook,
and the other, we need both MFC and Windows API.
My main reason for replying - I'm afraid this is incorrect. If you look up Window hook in the MSDN, the top two matches are for Windows hooks in Win32. I'd also be amazed if you couldn't write network code without MFC. Given that we're given the MFC source the worst case for someone unable to use MFC for whatever reason is a trip to the source to see how they do it.
MFC is a powerful class for GUI application, but we also need the knowledge
of Windows API.
Again, could't agree more. I don't use MFC anymore, and I'm enjoying learning life without it.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I'm writing an MFC app and I want to access, check out, check in, stuff from a SourceSafe database. Could someone give me pointers or links to a description of how this is done? Even better would be sample code
Everything I've ever found about SourceSafe is how to use it in Visual Studio and not actually how to implement interface to it in a program.
Thanks
===================
Eric "ArchV" Fowler
Ritual Entertainment
|
|
|
|
|
Look on the Microsoft website for something called Repository.
|
|
|
|