|
I've managed to manifest my problem without CMemDC so it is my code thats causing it.
It seems it's related to my drawing code.
Thanks for your help anyway.
|
|
|
|
|
this thing:
::SendMessage(::GetDlgItem(m_hWnd, IDC_LIST), LB_ADDSTRING, 0, (LONG) achKey);
adds a string to a listbox. Is it possible to add it into a control list as a subitem or just add it?
==============
www.design.kg
|
|
|
|
|
First of all, you need to seperate this, so you verify that the GetDlgItem call does not return NULL. Then you can use LB_INSERTSTRING, as I recall.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Like this?
::SendMessage(::GetDlgItem(m_hWnd, IDC_LIST_ACCOUNTS), LB_INSERTSTRING, 0, (LONG) achKey);
its add nothing and I'm sure that GetDlgItem call does not return NULL.
==============
www.design.kg
|
|
|
|
|
Karavaev Denis wrote:
I'm sure that GetDlgItem call does not return NULL.
I'm sure too, but that does not make your code safe.
I'm not sure exactly what you want to do here - add a string to a substring ? Or do you want LB_SETITEMDATA ( associate a value with an entry )
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
My app read key names from registry.
I have a sample that add this names to a list box I wana do the same, but to a Control list.
Is it possible?
==============
www.design.kg
|
|
|
|
|
Hi everyone,
The piece of code below uses MSHTML to modify the DOM of a page i have loaded into a CHTMLView. The code works correctly and the page is modified.
My problem is that when the user clicks on another name i need to load the original page template again and modify it again. I thought that by adding the LoadFromResource(IDR_DETAIL_HTML) line the original page would be reloaded and everything would be fine but when i execute it the modification stops taking place. It seems as if the LoadFromResource is being delayed or something and overwriting the modifications.
Does anyone know a way around this problem?
void CDetailView::DisplayDetails(CMessage *msg)
{
// LoadFromResource(IDR_DETAIL_HTML); <-- this is causing the problem.
IDispatch* pDisp = GetHtmlDocument();
if (pDisp != NULL )
{
IHTMLDocument2* pHTMLDocument2;
HRESULT hr;
hr = pDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pHTMLDocument2 );
if (hr == S_OK)
{
IHTMLElement *pBody;
BSTR bodyText=0;
hr = pHTMLDocument2->get_body(&pBody);
ASSERT(SUCCEEDED(hr));
ASSERT(pBody);
pBody->get_innerHTML(&bodyText);
CString bodyStr(bodyText);
::SysFreeString(bodyText);
TranslateText(&bodyStr, msg);
// Check this
pBody->put_innerHTML(CComBSTR(bodyStr));
pBody->Release();
pHTMLDocument2->Release();
}
pDisp->Release();
}
}
|
|
|
|
|
Hi,
I have an internet client application which reads the binary data sent by webserver. I want to display a progress control at the client-end when downloading a file. At the server-end, I am using TrasmitFile to send a file and sending content-length along with it. The problem is that, when I start reading the contents after I do Queryinfo for content-length, I even read content-length header into the buffer, which I don't want to.
How do I avoid headers and read only the binary content sent by server.
Do I have to override something at the server end when I am forming the headers?
Please can anyone answer my question.
Thanks in advance,
Cheers,
mythili
|
|
|
|
|
Hi,
I have a custom control that I would like to convert to an OCX activex object.
Is it possible? and if so any hints on were I can start. Any info or source code that can help would be appreciated.
thanks
Yaniv
|
|
|
|
|
Dear all:
I'm wondering why MFC makes all of its class's ctor protected? Why not public?
|
|
|
|
|
This simply isn't true. If all MFC classes had protected constructors, you'd be unable to construct them. If any DO have protected constructors, it's so you can't construct them unless your class is a friend of the class in question.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
One example is CView and its derivatives. Its constructor is protected which means that it can only be created by one of its numerous friend classes such as CDocument, CDocTemplate, CFrameWnd, CMDIChildWnd, and CMDIFrameWnd.
|
|
|
|
|
Hi Christian:
See you again
Here is the code MFC generate for my class.
I know why the DECLARE_DYNCREATE(EventLog) is protected, but I don't know why EventLog is protected, although the comment said "dynamic creation" will do this.
thank you.
/////////////////////////////////////////////////////////////////////////////
// EventLog view
class EventLog : public CObject
{
protected:
EventLog(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(EventLog)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(EventLog)
protected:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~EventLog();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(EventLog)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
|
|
|
|
|
Alex Dong wrote:
know why the DECLARE_DYNCREATE(EventLog) is protected, but I don't know why EventLog is protected, although the comment said "dynamic creation" will do this.
..so that you can not create the class using standard C++ ways, such as creating them on the stack or on the heap using new operator. MFC wants you to create these classes using its own specific way, such as the one used by CObject's ::CreateObject() method. Creating this way would allow you to save extra runtime information. If you dig into MFC source code related to document-view classes, you will find more on how these objects are created.
Hope this helps.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
I think Christian was taking issue with your use of "all" in your statement. Obviously things like CString and even CWinApp or CWnd don't have private constructors.
The answer is in the MFC FAQ (actually, it's credited to me, though I don't remember answering it... must have been like 7 years ago when I was active on the MFC mailing list, that's when I was using the name credited).
Odd.. I just went searching for the FAQ and it seems to have disappeared from the face of the internet (except a very early version).
Anyways, the gist is that CView and several other types are created dynamically by the framework without using new. (it's part of the CObject stuff). The constructors are marked private because originally the classes were not createable in any other way (they needed to be hooked up to the framework to function). They have since changed the framework so that you can create View's outside of the framwork, but the constructors are still private.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
One reason for making a constructor protected is to ensure that users of the class always properly construct the object using an initializing public constructor.
CFoo* pFoo = new CFoo();
CFoo* pFoo = new CFoo (bar);
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
I have a binary file that stores information about user settings. But, when I look to save the bar state information, it does not allow me to get the data, instead writes it to a profile (ini file / registry). Any ideas to do this?
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
The save bar state functions are written to write to the registry or ini files, no surprises here.
You'll need to look at the MFC source and write your own version of these functions if you want to save to your own file.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I want to populate and delete an stl vector using several threads.
Also one of the threads if going to sort the vector.
I derived a class from vector <t> and then put a mutex at the beginning of some methods. But I am not sure what to do with iterators.
When std::sort is called i do like this.
std::sort (vectr.begin(), vector.end())
I think this is not thread safe ?
I don't want to create a new method for the class and use the sort in the because I am sorting the vector according to many different criterias.
What do you think I should do ?
If you have a thread safe vector can you please send it to me ?
Orcun Colak
|
|
|
|
|
Thread safe containers are up to the user. You will have to protect access to your vector with a mutex or critical section.
Also note that it's not recommended to inherit from vector or any other container since none of them have a virtual destructor. It's better to use your vector as a member variable.
Todd Smith
|
|
|
|
|
Thanks Todd for your help.
Orcun Colak
|
|
|
|
|
I handle this message in my Win32 app, in order to not allow the user to size the window below the width of my tool area, which is variable, and to not allow sizing the floating tool window below the width of one button (alsovariable ), plus slider if necessary.
This worked fine up until a day or so ago. That is to say I noticed yesterday that it stopped working at some point. Now the minimum width is always 100 for all windows, no matter what. I've tried hard coded values in WM_GETMINMAXINFO, but they only work if they are greater than 100. Any width less than 100 seems to clamp to 100, and I don't know why.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Can you show me some code, Christian? I dealt with this problem a couple of weeks ago when Steen gave me a helping hand. I managed to get mine so that it could set the max width etc. to 0. Have you reset the lpMMI->ptMinTrackSize to (0,0)? It may default at (100,100)? Hope this helps you Christian, since you`ve helped me countless times in the past.
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
Ok.. I have this service, runs GREAT!! then I have this socket, runs CRAPPY.
With Naughter's testsvr's example I had taken the beeeep out of the main while loop and put a Thread that runs my Listening socket. I have a log that I can go to, to see my progression in the code.
My thread does initialize the socket and it creates it. I receive no errors. Then my client who is going to connect to my socket trys to connect. The "client" says it connects fine but the Service/Socket doesn't get to that point. This is where the problem is. The OnAccept for the Listening socket does not get called. This is a total MFC app. It is not a console app so I am assuming that I do have a message pump. I could be wrong too. If anyone has tried Sockets with servers I would appreciate any help. I have exhausted all my resources and I am really not sure this could be done. If someone can even tell me it can't be done I would appreciate that too.
Thanks in advance
|
|
|
|
|
I have two classes in a MFC DLL that use AFX_EXT_CLASS to export the classes (like below), but when I link it up to my application and include the header files for the classes I get a lot of errors (error C2228: left of '.Disconnect' must have class/struct/union type) - meaning the functions in the class don't have any code for them... but they should be in the DLL. Here are the classes I am trying to export. Any help would be good on what I am doing wrong, this is my first DLL experience. Thank you.
class AFX_EXT_CLASS CFirstClass
{
}
class AFX_EXT_CLASS CSecondClass
{
}
|
|
|
|