|
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5490)
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
crewchill wrote: I found this code a little confusing.
Yes. Working with legacy code I often find confusing items or constructs. My initial reaction is, like yours:
crewchill wrote: Am I missing anything fancy with the construct here?
Then later it becomes apparent that the author was just stupid.
On the bright side, tomorrow is FRIDAY!
|
|
|
|
|
Amen to Friday. My head is about to explode already.
You know the scariest part was, this is quite recent code.
The older version didn't have this and somehow the extra "const" appeared after it's being code reviewed
Not by me, mind you.
|
|
|
|
|
Hi,
MFC - VS2005, based application.
I have a number of objects, derived from the same base class. In the future I expect to be adding more.
Two views are provided on my app a CView based splitter, one is a simple list of the available objects the other is pane within which I would like each object type to render itself.
The view of each object while complex will have some similarities so I would anticipate a display class with inheritance etc.
So what might be the best way of implementing this display ?
Derive my display objects from CWnd and as the user selects each one in the list pane create and inject a new display object into the CView client area ?
Or ???
Many Thanks,
Paul C
|
|
|
|
|
How about a splitter window?
"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
|
|
|
|
|
Hi David,
I have a splitter window.
One view is the list of available objects (which is pretty simple ) and the other is the view of the selected object.
If the second view has contain all of the code to be able to render each object type then it will be an enormous amount of code.
The list of available objects will be extended in the future and I was trying to come up with a way of having each object be able to render itself rather than have the one view 'know' about all of the objects and ultimately each time an addition was made it breaking previous code.
Or is this just a dumb idea for a Thursday afternoon....
Paul C
|
|
|
|
|
PRC wrote: Or is this just a dumb idea for a Thursday afternoon....
No, Yes, Maybe. It depends.
If these object's primary responsibility is to render then it's fine.
If these objects have more business oriented responsibility then adding rendering to them is not a good idea. Separation of concerns[^] In that case you could consider designing a rendering interface and implement however many renders you need for each type of object. You might use inheritance or any other design for the renders.
|
|
|
|
|
Hello,
you can define a draw function for each object in its class, and make that class inherited from an interface.
class Object
{
.....
virtual void draw() = 0;
....
};
class Circle : public Object
{
virtual void draw() {}
};
and call each objects'draw method in the view.
you may also want to look at the visitor pattern.
Hope this helps.
Bekir.
|
|
|
|
|
PRC wrote: ...and the other is the view of the selected object.
Which (I think) would require a separate CView -type class for each. In the pane that controls the list of available objects (e.g., OnItemChanged() method if using CListView ), figure out which object is selected and tell the splitter window to change to the corresponding view.
I did this once with a gymnastics-related application. I only had 3 items in the left pane, however.
"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
|
|
|
|
|
Thanks to all for the response.
Led Mike - think you may have me sorted on this one.
The objects primary intent is not to render so you are correct that Separation of concerns would suggest my idea was a bad idea.
Thanks to all for the response.
Paul C
|
|
|
|
|
|
Hi, this is the C++ forum and you're asking an MSI packaging question. Does this ring a bell?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Maybe it is based on a GUI object...
Preparing for 70-536
|
|
|
|
|
Hi All,
On an INI file I want to delete a key-value. Using WritePrivateProfileString I can add a new entry. How can I delete a one
Thanks a lot
I appreciate your help all the time...
CodingLover
|
|
|
|
|
|
CodingLover wrote: Using WritePrivateProfileString I can add a new entry. How can I delete a one
using the same thing. See the parameter values
lpKeyName
[in] Pointer to a null-terminated string containing the key to be associated with the string. If the key does not exist in the specified section, it is created. If this parameter is NULL, the entire section, including all entries in the section, is deleted.
lpString
[in] Pointer to a null-terminated string to be written to the file. If this parameter is NULL, the key pointed to by the lpKeyName parameter is deleted.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
As you probably know, there isn't a function like, for instance, DeletePrivateProfileKey . Hence, I see two possible approaches:
(the quick one) Use the WritePrivateProfileString function to invalidate the key, assigning it a well-know string (for instance empty string).(the cumbersome one) Read the whole ini file and create a new one with only the sections and keys you want to retain.
Well, looks like I was wrong...
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]
|
|
|
|
|
Even I want to read the file and remove the unwanted key make mess for me. That's why I look at an API
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Ok, i figured it out.
But now I have another messup. All my keys are in a combo box. I want to get the selected text, or the key. Please help me to do this.
ComboBox_GetText doesn't make sense sir.
Please help me.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
By using CComboBox::GetCurSel you can get the index of the selected item and then use CComboBox::GetLBText()
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Actually I use standard C controls. I only know the ID of it.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
See the messages that you can use with a combo box control then. For instance, CB_GETCURSEL[^] instead of CComboBox::GetCursel().
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi forum!
I'm wondering how could I read the word behind the mouse pointer. Let's say my app. has a CRichEditView and when user stops moving the mouse I want to grab the word that is under the pointer, so I can show a tooltip with certain info. Yes in a fashion like Visual Studio displays a variable value when you mouse over it in debugging mode.
After googling for a couple of days I've just found some approaches like using IAccessible class from MS Active Accesibility:
http://blogs.msdn.com/oldnewthing/archive/2004/04/23/118893.aspx
But it just gives the whole content of the view. And I guess it's not trivial to get the mouse coordinates and translate it into a document position.
Any clues, code samples, references or even claps in the shoulder will be much appreciated.
Thanks in advance
|
|
|
|
|
|
Thanks Stephen! It's just the idea I'm working on now, and it seems to be taking me somewhere... after two days wandering around silly approaches.
Just a couple tips for possible readers:
If like me you're playing with OnMouseMove and a CEdit control, remember that
a) It's the control itself not the containing window wich may handle the WM_MOUSEMOVE message (a couple hours lost for a newbie like me). One way to achieve it is to derive your class from CEdit, place the message handler there and bind your ICD_MY_EDIT_THING with a control variable of this class (DDX stuff).
b) Of course it's the control who has to SendMessage(EM_CHARFORMPOS, ...), so do it in the above mentioned message handler.
c) Watch out the difference of SendMessage LPARAM parameter deppending on you're working with a CEdit or a CRichEditCtrl.
Hope this saves others time and frustration
|
|
|
|