|
I realize that, but since you are not actually doing any formatting, why not just use:
m_sHex = _T("FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF");
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
hello guys... I am trying to get the client area of my CListCtrl which shows vertical scroll bar when needed. The View is set to Report. Now, to prevent horizontal scrollbar, I am setting the width my column manually like this.
LVCOLUMN col;
CListCtrl->GetClientArea(&Rect1);
col.cx = (Rect1.right - Rect1.left) - 20;
But I want to set the width of my column based on something like this
CListCtrl->GetClientArea(&Rect1);
GetClientArea(ScrollBar of CListCtrl)
LVCOLUMN col;
col.cx = (Rect1.right - Rect1.left) - Width of Vertical ScrollBar;
But I don't have a clue how to get width of this built-in scrollbar OR how to get width of CListCtrl exluding ScrollBar? Thanks for any pointers.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
GetClientRect() (not GetClientArea) returns the client area of the list control. The area of optional scroll bars is not included in the returned rectangle. So GetClientRect() returns different rectangles when scroll bars are present or not.
The size of the vertical scroll bar can be determined using GetSystemMetrics(SM_CXVSCROLL) . You may use this value upon list initialization (with empty list when no vertical scroll bar is shown) to preserve space for the scroll bar.
|
|
|
|
|
How can I provide one instance only for an object ? And here I'm not refer to CMyWinApp (one instance of an application), but a custom object ? It's an interview question ...
|
|
|
|
|
Hint: singleton.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Create a static count in the object and increment it in the constructor?
|
|
|
|
|
Ok, and when second instance is about to be executed, how can I stop it then ?
|
|
|
|
|
Use a get instance static member func to do that.
|
|
|
|
|
In header file:
class myUniqueClass {
private:
myUniqueClass(); myUniqueClass(const myUniqueClass&); static myUniqueClass* myUniqueInstance;
public:
static myUniqueClass* getInstance();
};
In cpp file:
myUniqueClass* myUniqueClass::myUniqueInstance = 0;
myUniqueClass::getInstance() {
if (myUniqueInstance == 0) {
myUniqueInstance = new myUniqueClass;
}
return myUniqueInstance;
}
Explanation:
The two private constructors prevent the uncontrolled creation of a new instance, or the copying of the one, valid instance. The getInstance function creates the one instance if necessary: as a member function it can use the private constructor.
|
|
|
|
|
And when I want to work with this object, I write :
myUniqueClass* pUniqueClass = myUniqueClass::GetInstance();
I'm right ? And what is happen when object goes out of scope ? I have memory leak ?
Stefan, I thank you very much !!
modified 6-Jul-12 6:38am.
|
|
|
|
|
Of course there is nothing to stop someone totally ignoring the GetInstance func and just creating their own, so it depends on your question, do you want to *force* users to have only one instance.
|
|
|
|
|
I think that is impossible to create a new instance of myUniqueClass because have private constructor ...
|
|
|
|
|
Good point.
|
|
|
|
|
Correct. getInstance is used to access the single object.
You are correct that the code above produces a memory leak. The problem is that the only way to avoid it is to create and destroy it from another singleton! In a windows application, you could implement that in your WinApp class. In a console program you could do it in main() .
Also, as Luc Pattyn mentioned in his response, my code can not prevent the creation of a second instance in multithreaded code: the creation of the instance (and the preceeding test of the pointer) has to be locked. However that is only a problem until the first instance is created, so you can solve this by creating the instance at the start of the program in main() or your WinApp class.
|
|
|
|
|
And what about thread safety? If you're unlucky two threads calling getInstance() at the same time may cause two objects being created. There are many ways to create a Singleton pattern, lots of the attempts are just wrong, only a few are correct without showing too much of a performance hit. Look at several articles on the subject here at CP, or elsewhere.
|
|
|
|
|
Yep, of course it needs lock protecting.
|
|
|
|
|
True. If you asked me how to implement a singleton in a multi-threaded environment, I might have thought of that
Oh well, maybe I'm just lucky that the things I work on involve virtually no multithreading at all!
|
|
|
|
|
This is an academic question - can standard MFC CSplitterWnd class be easily modified to allow floating static views?
There are few posts here about splitter window which do wonderful things, but not necessary easy to adopt.
Ideally I would like to have ability to select a view in sort-off pop-up fashion - make a duplicate and be able to move it around / re-size etc.
Any opinions are welcome.
Thanks for you time.
Vaclav
|
|
|
|
|
You can change the size of a splitter window by dragging the splitter bar and/or resizing its parent window. If you want a floating window then that is a different thing altogether. Perhaps you could explain some more of what you are trying to do.
|
|
|
|
|
I have an application ( ham radio logging program ) which have / needs several views of the database document - mostly different files and some statistics.
The main interaction with user is simple data entry, one view in real time, and than updating the views.
I need to keep minimal mouse / keyboard interaction to manipulate the auxiliary views.
Using splitter is OK, but I would like to be able to “pop-up” the main view and keep the splitter running in the background.
My goal is – minimal mouse interaction ( the user is using both hands to “work “ the hardware already ) – say using function keys to do this, maybe even voice interface.
|
|
|
|
|
You have a number of options:
- use an MDI window so you can control which child window is at the front
- have a full-frame child window that you show or hide on demand
- have a separate frame window independent of your main one
There are probably other possibilities that you could consider; it all depends on how you want to interact with your users.
|
|
|
|
|
Hi, all!
I'm addicted to VC++ since 2008, and I begin to work for my current company from 2011 when I graduated in Mathematics. Now I still love VC++, it is a wonderful programming language.
Now I'm a little confused whether it's a good idea to continue with Windows Programming.
Now I'm in Beijing, China. Of course, I come from China. I want to find a work in Silicon Valley, America in the future.
Can anyone tell me is it possible for me to find a VC++ work in Silicon Valley someday in the future? And what should I do in the recent years?
Any help would be greatly appreciated!
modified 5-Jul-12 20:51pm.
|
|
|
|
|
Falconapollo wrote: is it possible for me to find a VC++ work in Silicon Valley someday in the future?
Who knows? The world might end, the companies may move north or east, some new technology may make them all redundant ...
Falconapollo wrote: And what should I do in the recent years?
Again, how can anyone say without being able to predict the future.
A much better idea would be to look around your local area at the companies that are hiring and see if you have, or could learn the skills that are in demand. The more different languages and frameworks you can work with the more chance there is of getting a better job in the future.
|
|
|
|
|
Thank you.
Your answer is short but useful.
|
|
|
|
|
Falconapollo wrote: Now I still love VC++, it is a wonderful programming language.
That is a bit general.
C++ is a programming language. And the MS implementation is a fairly decent (these days) implementation of that.
Managed C++ is also a programming language. It derives from C++. It might be a strict super set, but one would need to looks at the specification to determine that.
The windows API, are libraries which one uses with a programming language.
Falconapollo wrote: And what should I do in the recent years?
Learn SQL, probably TSQL (Microsoft SQL Server). SQL programming is significantly different that programming in C++ (or C, Java, C#, for that matter). So it gives more breadth to your knowledge. Plus relational databases are not going to go away.
|
|
|
|