You are using the GetSel() method to get the starting and ending positions of the control's selected text, correct? I tried that and with all of the text in the control selected, I found that CR and LF are (like I would expect) considered two separate characters. In other words, start = 0 and end = 7.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
I use the Streamout api to get whatever is in the control the edit control has 4 lines at the end of each line is X0D0A CRLF I have to count the 0X0D0A as 1 character for the SetSel api when determining the pos I want to use in the selection
This is Familiar, in particular with the multi threaded question you asked earlier.
MFC cannot realy handle multiple threads. No one seems to know why, I have asked the question before.
At any rate, the only way MFC objects can communicate between threads is with the Old Fashioned WDK Kernel Function ::SendMessage(hWnd, Param1,Param2);
In MFC you create your Message as WM_USER+(X), Create a Message Handler, and, manually add it to the message map.
Any attempt to call an MFC Object from a different thread than in which it was created always ultimately lead to failure.
The Symptoms are: Works, Add a Virtual Function: It stops Working
No I Did Not intend this for you.
This topic became a Sort of a Labyrinth.
The Original Person is evidently out of his/her depth! (S)he is still hammering the subject I see.
I try to help, as we all do, but can get frustrated when good advise is ignored, as, I am sure you do to.
This message returns the number of characters copied, not including the terminating null character.
The call is terminated by the null character and if you have CR,LF they will count as characters
The return is a CHARACTER COUNT, if your edit box is unicode mode it still reflects the character NOT THE NUMBER OF BYTES.
Hence when providing a buffer you are best to use an array of TCHAR rather than a standard byte array to allow for size difference.
Also note when size a TCHAR array use _countof DO NOT use sizeof for the same reason. Standard unicode aware coding practice.
Several of the comments have confusion between CHARACTER and BYTE within the meaning of the windows API. No such confusion exists.
I had a confusion that why we can use :: sign in calling static member function of class.
while in the case of calling simple member function using :: sign shows error .. in c++.
Please explain .
Member functions need qualifiers in order for the compiler to know which function your code refers to. In the case of a static function the qualifer must be the class name, since static functions belong to the class: hence Class::Function(). For member functions the qualifer must be the instance reference, as non-static functions are attached to individual objects: hence object.Function() or objectpointer->Function().
Which line does it occur on when you step through it, and what is the assertion being hit?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
I have a dialog based MFC application that I am rewriting in VS2010 from its original VC++ 6.0 source. Everything works fine in VC++ 6.0
The main dialog contains many child dialogs (not pop-ups) in which one child dialog is used to draw a plot based on the values sent from main dialog. The main dialog calls a function (Draw_Points) within the child dialog and the child dialog draws it and it does as long as the plot hits the edge and then it calls OnPaint message to refresh the dialog so that it can start afresh from left.
void CPlotDlg::Draw_Points(double value1, double value2)
if(m_LastPoint1.x < (m_time_rect.right-2))
// Store the data for later retrieval
m_CurrentPoint1.x = m_LastPoint1.x + 1;
m_CurrentPoint2.x = m_LastPoint2.x + 1;
// Do some calculations
m_Data1[m_DataCounter] = value1;
m_Data2[m_DataCounter++] = value2;
CWnd *Ctrl = GetDlgItem(IDE_PLOTS);
CDC *cdc = Ctrl->GetDC();
HGDIOBJ original = NULL;
original = cdc->SelectObject(GetStockObject(DC_PEN));
m_LastPoint1 = m_CurrentPoint1;
m_LastPoint2 = m_CurrentPoint2;
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CWnd *Ctrl = GetDlgItem(IDE_PLOTS);
// Do not call CDialogEx::OnPaint() for painting messages
It crashes when the Draw_points function calls OnPaint function in its else section, and when OnPaint() function executes CPaintDC dc(this);
Well, you need to rethink your design. You should collect all the information related to the drawing as a result of user interaction, file processing etc. You then call InvalidateRect to tell Windows that your data has changed, and your window/client needs to be repainted. Then in the control you call your paint function in response to receiving a WM_PAINT message. It is at that point that you draw your lines, shapes, text etc.
Well, the first step is to create a query ( the easiest way would be to create it and test in the MS Access).
The second step - create the recordset that supports update and insert operations. See MSDN article [^] for details.
I am stumped again. I have this macro which expect the parameter registerSAM to be a symbol , for example PIO_ODSR. I like to pass such symbol to a function and just have no idea how to convert char* to such symbol.
The compiler is not much of a help, just flags an error.
I do not see any macro here, and I really cannot understand what all the above is supposed to do. It would really help, as I have suggested many times, if you showed the actual code clearly, and within <pre> tags so it is readable.
And I think you really do not know the answer and just wasting your time. If you bother to follow the thread I did mention I tested it without the & and it did not work. I suppose since I did not use code tags correctly it is my fault. Thanks, go back to policing the posts. You do that very well.
Your size parameter values need to be scaled for output to a printer. When drawing to the screen 300 is the number of pixels, but when drawing to a printer it is the number of dots. See SetMapMode function (Windows)[^].
My application don't want to create any entry in registry. If I comment SetRegistryKey(_T("Local AppWizard-Generated Applications")) then application throw an Assert failure. How to overcome from this problem.