|
What does the error message say?
|
|
|
|
|
Error 1 error LNK2019 : unresolved external symbol "public: void __thiscall CEdit::SetHighlight(int,int)"
(? SetHighlight@CEdit@@QAEXHH@Z) referenced in function
"protected: void __thiscall CReceivedMessageEdit::OnLButtonDblClk(unsigned int,class CPoint)"
(? OnLButtonDblClk@CReceivedMessageEdit@@IAEXIVCPoint@@@Z) C : \...\ReceivedMessageEdit.obj
Error 2 error LNK1120 : 1 unresolved externals C : \...\123.exe 1 1 123
|
|
|
|
|
I would expect it to just send a message to the edit control and therefore be implemented as an inline function when reading CEdit::SetHighlight[^]:
Quote: This method sends the EM_SETHILITE message, which is described in the Windows SDK.
But getting a linker error assumes that there is a declaration in a header file but no definition (implementation).
Following the link from the above quote is even more extraordinary:
Quote: EM_SETHILITE message
This message is not implemented.
A quick research brought up this:
What’s the deal with the EM_SETHILITE message? – The Old New Thing[^].
So it looks like that the SetHighlight function uses a not implemented feature and can't be use therefore.
|
|
|
|
|
Yes I found that after posting my reply. However, I would still like to see the linker message.
|
|
|
|
|
The linker message is just going to say no body for prototype function found.
The ".H" file contains a prototype header, however the ".c"/".cpp" file contains no body code for that prototype.
So the compiler will basically see a forward declaration of a prototype which it will connect but when it gets passed to the linker it can't match the forward declaration to a code body and so it will report that accordingly.
The MSDN blog describes the problem they forgot to cull the prototype header before they got locked for compiler release.
In vino veritas
|
|
|
|
|
So the method is unavailable.
Any thoughts on how to make an edit box highlight part of its text in a different colour?
I thought I would have to write a custom paint routine to do this when I saw SetHighlight.
|
|
|
|
|
If it is just the current selection and using the default selection colour is appropriate, use the CEdit ES_NOHIDESEL style to show the selection even when the control does not has the focus.
Otherwise you may use a CRichEditCtrl .
|
|
|
|
|
Just override the draw method and put the text onto the DC in whatever colors you want depending on the state.
In vino veritas
|
|
|
|
|
Thanks for the suggestions; ES_NOHIDESEL looks like it will do what I need.
|
|
|
|
|
Hi,
I am using CCriticalSection and CSingleLock for synchronization purpose.
Is there a mechanism to test the synchronization object to know whether it is locked from another thread?
That is, I don't want to enter the lock, but just want to know whether the synchronization object is locked or not without blocking my code.
|
|
|
|
|
There would be a solution by getting the lock count from the undocumented <code> _RTL_CRITICAL_SECTION structure.
But there should be no reason to do that when using locks as intended (for short periods). For longer periods use other mechanisms like events.
|
|
|
|
|
Hello,
I am tryint to use CPaneDialog for implementing dockable Dialogs, based on a Dialog resource.
I started with the GestureDemo from Microsoft's MFC samples. There is an option dialog bases on CPaneDialog.
The demo works as it is.
I added to the dialog resource a ListControl.
Here is my problem. The Control is not displaying any content!
I tested the same dialog inside a standard CDialog. So actually my control works fine!
Is there anything additionally, I need to do in a CPaneDialog to interact with dialog controls?
Unfortunately I cannot find further source code samples.
Seems, nobody is using CPaneDialog.
Any hints? Thanks a lot!
|
|
|
|
|
How do you create the dialog?
How do you initialize the list control?
PS: sorry, I do not have the MFC samples installed on my PC, so I cannot test it myself!
|
|
|
|
|
Member 8534035 wrote:
Here is my problem. The Control is not displaying any content! How are you adding content? Where?
"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
|
|
|
|
|
sorry for the late reply...I was absent a while!
in the meantime I lost my first trail project and did it again, somehow differently
but it is still not working!
My steps in detail:
1. Using the original source code from VS Gesture Demo
2. Adding a ListControl to the IDD_OPTIONS Dialog resource (report style) ID: IDC_LIST_INPANE
3. doing the same what the framework would do automatically for a standard dialog:
- in OptionPane.h I added
CListCtrl m_ListCtrl;
- in OptionPane.cpp in DoDataExchange
DDX_Control(pDX, IDC_LIST_INPANE, m_ListCtrl);
4. Added a Handler for WM_INITDIALOG
LRESULT COptionsPane::HandleInitDialog(WPARAM wParam,LPARAM lParam)
{
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(lParam);
m_ListCtrl.InsertColumn(0,_T("Col1"),LVCFMT_LEFT,50);
m_ListCtrl.InsertColumn(1,_T("Col2"),LVCFMT_LEFT,50);
int nItem;
nItem = m_ListCtrl.InsertItem(MAXINT,_T("Item1"));
that's quite all!
Now, when I am starting the program, I will get an assertion in HandleInitDialog at the first access of m_ListCtrl. It seems m_hWnd is not valid at this moment.
What I need to do additionally in comparison to CDialog (where I initialize the control in OnInitDialog())
Is CPaneDialog::HandleInitDialog the wrong place for initialization of controls?
|
|
|
|
|
5 years later I have the same problem! Have you found the solution?
|
|
|
|
|
You need to call at first the CPaneDialog::HandleInitDialog(wParam, lParam) to create all the Dialog members.
|
|
|
|
|
Hi
I have successfully Created a bitmap in my static control thru Overriding CStatic::DrawItem
problem is it freezes my application
I know why Draw Item is constantly Being Called
When I SetRedraw(FALSE)I can see it, However when a window covers the bitmap it gets erased
There is I am missing I am not sure what it is
|
|
|
|
|
Hi
I don't get this but CStatic::DrawItem is a override in Win32 WM_CTLCOLOR is a message
So I got to thinking once I overrode CStatic::DrawItem I don't need a message map
I moved other windows over my CStatc Bitmap and it remained intact no freeze up
|
|
|
|
|
MFC is weird in a number of areas it isn't equivalent to the WIN32 API in a great many respects.
You have run across this a number of times with things like it is a singular thread, it's modal dialogs are in fact not WIN32 modal in MFC they become modal via the message loop. You seem to have identified MFC static text has got some different behaviour as well.
The thing about SS_OWNERDRAW on a true Win32 static class is you don't override it on the static itself but rather the dialog owner is sent the WM_DRAWITEM message and it is expected to handle it for the static class
In the Win32 framework it is very explicit
About Static Controls (Windows)[^]
By using the SS_OWNERDRAW style, an application can take responsibility for painting a static control. The parent window of an owner-drawn static control (its owner) receives a WM_DRAWITEM message whenever the static control needs to be painted. The message includes a pointer to a DRAWITEMSTRUCT structure that contains information that the owner window uses when drawing the control.
My biggest reason for not ever using MFC is that you can't mix pure Win32 code with MFC easily and reliably. The newer WPF framework allows Win32 Interoperation with only a limited few restrictions. For example in your case it would have been nice to have just written a nice pure Win32 dialog code to do what you want but MFC can't call a native Win32 dialog process because it has its own message pump loop and it's dialogs aren't really modal.
If you want to look at the message pump which is very MFC specific goto CWnd::RunModalLoop function and you can see how it pumps messages into the framework via
AfxGetThread()->PumpMessage()
If you are using MFC you need to ignore native Win32 it won't always work. Probably use it as a guide as how it might work if MFC not as how you should do it on MFC. From you prior answer it is also obvious MFC window frames aren't exactly like Win32 native frame either.
If your project isn't large I think you have now reached a level of understanding of Win32 you could dispense with the MFC framework and just have a pure Win32 application. You seem to spend more time fighting the framework than actually coding new stuff. So the question I would put to you would be what do you like about the MFC framework, what positives do you have.
In vino veritas
modified 16-Aug-16 3:49am.
|
|
|
|
|
leon de boer wrote: MFC is weird in a number of areas Very good advice, I remember when I first tried mixing Win32 and MFC I had problems.
|
|
|
|
|
To Answer your question When looking at Windows apps almost all are C++ just look at the articles examples on The CodeProject What % is Win32 and how much is MFC I would say 80 % of the Windows examples are MFC why is that ? Of course now C# seems the way to go by that is for Web Development
What do most people use for Windows Developement ?
|
|
|
|
|
ForNow wrote: What do most people use for Windows Developement ? I use pure Win32 from C++ and find it works just fine. I used to write MFC in my professional life but found it over complicated in many areas. I also use C# and find that so much easier, and more powerful than MFC.
|
|
|
|
|
When you say you use Win32 C++ you develop your own Classes ?
You say C# is more power full how so it doesn't have pointers from what I understand
|
|
|
|
|
ForNow wrote: ...it doesn't have pointers from what I understand And that makes a language powerful? Some find pointers, especially those that point to other pointers, a deterrent. It all depends on the person wielding the tool, not the tool itself.
"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
|
|
|
|