|
Member 3375334 wrote: old lines are not being erased like in MFC one. I thought by doing PushMatrix will do the trick...
PushMatrix doesn't change anything of what is already drawn on the screen. In fact what you are doing is drawing things on a buffer that was not cleared. Because of that, your previous lines are still visible: it's a bit like drawing things on a paper, if you don't erase what's already on the paper, it will still be visible. MFC and OpenGL work completely differently on that aspect (and on many others).
PushMatrix simply pushes the current model/view matrix one place down the stack so that you can 'save' it for later. This model/view matrix is simply a matrix that will be applied to points in your model in order to position them correctly.
Also, your design is a bit ugly. You should draw things in your mouse handler. Instead you should store your data and put all the drawing code in the OnPaint handler.
For your other questions, I don't really understand what you are trying to do: it seems that you are drawing both from MFC and from OpenGL on the same window. In that sense, chances are that you will only be able to see the results from one of the two. Why do you need to have MFC and OpenGL drawing on the same window ?
|
|
|
|
|
Ok the fact that my code is so ugly is because i am brand new to all this so please don't be judgmental
the reason why i am doing it in mousemove..is because that's what i need to do.. i need to draw on mouse move not paint. when i move my mouse i should be drawing lines. So that's right. The reason why i need to see MFC is because that's what i need to do based on the requirements.
where should i do clear?
|
|
|
|
|
Member 3375334 wrote: Ok the fact that my code is so ugly is because i am brand new to all this so please don't be judgmental
I don't judge you, I was just saying that what you did is not the best design.
Member 3375334 wrote: the reason why i am doing it in mousemove..is because that's what i need to do.. i need to draw on mouse move not paint.
Of course, but storing your information (the coordinates of each lines for instance) in the mouse handler and forcing a repaint of the view will have the same effect. Besides, all drawing code from the MFC has to be put in the OnPaint handler, otherwise if your window is hidden for a while (even partially), all the MFC drawing will be lost because windows doesn't store any information about what to draw but instead issues a WM_PAINT message and lets the window repaint itself. As you didn't provide any drawing code there, everything is lost.
Member 3375334 wrote: The reason why i need to see MFC is because that's what i need to do based on the requirements.
And what are your exact requirements here ? Because I don't see any reason why you would need to use MFC AND OpenGL on the same window. How can you expect to see one drawing through the other one ? I'm not an expert in mixing MFC and OpenGL drawings together, but I think this is not possible (not sure about it, but it sounds really strange anyway). Think of it this way: imagine that OpenGL and MFC are painting things on a buffer (like a real life painting). Now, each of them puts its buffer on the screen ("they hang their paintings on the wall" ). So, you can't see both of the paintings at the same time...
Besides, another strange thing is that OpenGL and MFC have different levels of 'abstraction': with MFC, you draw things on your screen and everything is 'pixel based'. With OpenGL, you are one level higher: your model have a space which is converted to screen coordinates by OpenGL. In your case, it happens that your units in the space correspond to pixels because you configured OpenGL this way. Suppose now that you want to add features like zoom, which is easy to do in OpenGL, then the MFC drawing won't follow.
|
|
|
|
|
Hi,
I would like to to display a certin amount of Characters om a line of a Rich Edit
Dialog Box
Seems line the EM_SETFORMAT message with the Charaformat Structure doesn't give me as much flexibility as the data in thr Logfont sturcture
It seems Like CFONTdialog object give you more flexbility in setting a font of a dialog box
My quetion is does the CFONTDialog OBJECT Actually display a Dialog Box ???
As it seems after Creating the Object The User needs to invoke
the DoModal method to inquire or set the Font Values ???
|
|
|
|
|
ForNow wrote: My quetion is does the CFONTDialog OBJECT Actually display a Dialog Box ???
Only if you call its DoModal() method.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
IS there anything to get width of a charcter in a Rich Edit Control
as Logfong has lfWidth
|
|
|
|
|
CDC::GetTextExtent
BOOL ok = FALSE;
int richeditwidth = CRichEditCtrl::GetRect get richeditwidth
CFont font = CRichEditCtrl::GetFont
do{
1.CDC::GetTextExtent get stringwidth
2.if(stringwidth < richeditwidth)
{
ok = TRUE;
}
else
{
font size --
CRichEditCtrl::SetFont
}
}while(!ok);
hope this can help u .
|
|
|
|
|
ForNow wrote: as Logfong has lfWidth
You can still use the LOGFONT structure by first calling the GetLogFont() method. Something like:
CFont* font = richeditctrl.GetFont();
if (font)
{
LOGFONT lf;
font>GetLogFont(&lf);
TRACE("%ld", lf.lfWidth);
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I have been coding most this app in C seems like this might be a good time be a good time to go C++ OO MFC Cricheditctrl, etc
|
|
|
|
|
This is a lot like the question you asked two days ago:
http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2926253[^]
You can't just stab in the dark guessing at things.
If your question is:
"I have a window X pixels wide. Given a certain font, how many characters can I fit in the window?"
Unless the font is fixed width, then you have to ask the question the other way around.
"I have a string. I have a font. How many pixels on the screen will it take up".
That question you've had answered twice.
GetTextExtent is your friend.
I wish you luck - I'm sure you're getting very frustrated by now.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
I am A Assembler MainFrame Programmer By Day I have always wanted to Move to Newer Things OO e.g. CRichEditCtrl
pixels.... Are a whole new way thinking thankx for Being Patient with me .......................
|
|
|
|
|
Hi,
I wanted to do research before asking CRichEditCtr is a derived Class wHose Base Class is Cwnd
GetTextExtent is a member of Class CDC
thankx again I am on my way to MFC
|
|
|
|
|
There are many sources of confusion here.
CRichEditCtrl is a C++ object, whose base class is CWnd - true.
But both of these are just handy C++ abstractions of the underlying Windows types. CWnd wraps a generic HWND handle. CRichEditCtrl wraps up an HWND handle of a RICHEDIT window type, so it accepts extra messages.
A DC is a Device Context, and is a windows thingy that represents a drawing surface - whether that's a screen, a printer, or a pure memory area. A CDC is the MFC C++ class that wraps up an HDC (handle to DC) variable from windows. If you look at the code for almost any CDC member function, you'll find it calls window functions pretty immediately.
In order to show things on the screen, the OS passes messages to WNDS asking them to draw on a DC.
So, the main message for this is WM_PAINT. The OS knows that a window needs to redraw on the screen, and send this message to a window - and the message handler will call BeginPaint to get a drawing surface ready to draw on to. All of this work is wrapped up for you in MFC, and your CView derived class has an OnDraw member function with a CDC* parameter all ready fot you to work on.
I'm not going into much more detail - that's what books are for, not replies on this forum, but I hope it gives you some direction for your research.
Now on to your specifics...
If I understand you correctly, you want to know if a bit of text using a specific font will fit into a certain area. You've guessed at CRichEditCtrl, and you've guessing at CFontDialog, and neither have helped all that much.
There is no "throw away letters until this fits" routine - largely because windows has no idea which words / letters will be important to you. That's *your* job. But you can reverse the problem and find out how much room a given string will take up. Then chops bits away yourself until it fits.
Have a look at the following code, and make sure you look up the functions, as this is from memory...
CSize CMyDialog::GetSizeOfString (CString sTest, CLogFont *lf)
{
CDC *pDC = GetDC ();
CFont fTest;
fTest.CreateFontIndirect (lf);
CFont *fOld = pDC->SelectObject (&fTest);
CSize sz = pDC->GetTextExtent (sTest);
pDC->SelectObject (fOld);
ReleaseDC (pDC);
return sz;
}
When you're more used to it, you could have used CClientDC dc (this); , as it wraps the GetDC and ReleaseDC calls to make it harder for you to make mistakes.
I hope that provides some enlightenment! It sounds like you've got quite a long way to go - but people here will be happy to help with specific questions (ie, we can't teach you MFC in two or three replies) as long as you ask well phrased questions and can show you've tried yourself already. (which you did)
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi,
I have always been a sync (mispelled) but if I were to pay for course on MFC it WOULD cost quite a lot of money it nice to see some people helping out others for Free
Again My Background is MainFrame Assembler Internals worked for IBM in poughkeepsie on the MainFrame OS
This is a different way of thinking ....OO
I am going to do research on what you just sent
I am also going to read MFC C++ CLasses Book by Shirley Wodtke
thankx so much for your help
BTW the Window / Control I am inquiring about is a Edit Class of a Dialog Box all the Messages mentioned above
e.g. WM_PAINT
I have seen in Controls Were the Parent Window is a Regular Window
Not were the parent Window IS dailog Box
Hope my next question will be more intellgient
PS quite Early Here in the US on the East Coast White Plains NY
off to the GYM and then work (MainFrame PRog) will do research on what you just sent
Thankx Again
|
|
|
|
|
The edit control still has code handling WM_PAINT... it just does it on your behalf.
Same with a BUTTON control. The principles are the same.
And yes, this message driven stuff does take a mental shift.
Good luck with it though!
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi,
The MSDN doc says the return code from EM_GETCHARFORMAT reflects the Value
of dwMask which says which values of the Charformat structure are valid
so...........
If the return code From the SendMessage is zero this means that none of the
Vlaues are Valid
If so do I at somepoint in time have to do a EM_SETFORMAT first ????
|
|
|
|
|
ForNow wrote:
If so do I at somepoint in time have to do a EM_SETFORMAT first ????
How about trying it and see? First send it EM_SETFORMAT , followed by EM_GETFORMAT .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Ok
I have a related question but I'll start a new thread
|
|
|
|
|
I believe if you read carefully that the structure receives the formatting for the FIRST character in the selection, and the dwMask specifies which attributes are consistent througout the selection.
According to MSDN:
lParam
Pointer to a CHARFORMAT structure. If the selection formatting
is being retrieved, the structure receives the attributes of
the first character and the dwMask member specifies which
attributes are consistent throughout the entire selection.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
hello
please help about adaptive niblack binarization algorithm , so thai i can write the c++ code according your algorithm.
Thnking you
|
|
|
|
|
re-re-re-re-REPOST[^]!!!! And particularly blatant, as your previous post is still on the first page of the forum.
Try doing some research for yourself - a little Googling and some use of Citeseer[^] (the best search engine for academic papers, in my experience) leads me to believe the reference you want is 'Wayne Niblack, An Introduction to Digital Image Processing, pp. 115–116, Prentice Hall, 1986.'
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
May be again you can paraphrase Einstein [^]
Regards,
Sandip.
|
|
|
|
|
I wouldn't want to be accused of reposting
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: re-re-re-re-REPOST[^]!!!!
Nope: this time is adaptive.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
In my app I need to write something in some place on PC.
In my code I call 'std::ofstream' but first I have to make sure that file exist.
If file doesn't exist I need to make an empty file.
Now my question is, after I find out that file doesn't exist can I create it only by specifying full path-name not worrying if some of sub folders exist. It needs to recreate the whole path.
To be more specific the location is 'C:\....\Aplication Data\..".
How to achieve this?
Thanks
|
|
|
|