|
I had the same issue. What I ended by doing is resizing the columns when the vertical scroll is added. So instead of hardcoding the width of column, you assign it a percentage of the listctrl's width. Then call this function whenever your listctrl needs a vertical slider. The user can still resize the column with the header control (which could cause a horizontal scrollbar to appear).
void CMyDialogDlg::ResizeColumns(const int iPercentageOfListCtrl)
{
CRect rect;
m_cListCtrl.GetClientRect(rect);
int iNewWidth = (rect.right * iPercentageOfListCtrl / 100);
int iOldWidth = m_cListCtrl.GetColumnWidth(0);
if (iOldWidth != iNewWidth) {
m_cListCtrl.SetColumnWidth(0, iNewWidth);
}
}
This will resize the first column enough so that the list ctrl doesn't think it needs a horizontal scroll bar.
Hope this helps.
|
|
|
|
|
Hi,
thanks for reply.
when should i call this function, shall i call it
when OnSize() occurs???
Yaron
Ask not what the application can do for you, ask what you can do for your application
|
|
|
|
|
i need help for creating additional button on windows's caption area (near minimize,maximize,close)
for example, help, minimize to tray ... etc...
also i mean - to create many buttons (not one )
somebody can explain, or just give some URLs where i can find out this examples ..
PS : google doesn't help... and i can not find out it here ..
PPS: sory for my ENG;
----------------------------
never stop coding.
|
|
|
|
|
Hi,
Try this : http://freespace.virgin.net/james.brown7/tutorials/titlebar.htm
Florian Szoke
|
|
|
|
|
hi
i need a help in printing. in my project my window certain area i like to print not the entire client area. how can i print the data containing in the particular area on the window to printer.
thanks alot
from
venu
|
|
|
|
|
well presumably the user can select an area of the view to print somehow ... when they select print u would figure out what part of the data they have selected in ur document and send that to the printer
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" biz stuff about me
|
|
|
|
|
Hello everyone,
Wow. It's been a while since I've been here. I was doing some embedded stuff there for a while. It's nice to be back.
Anyway, the question that I had has to do with having the ability to cancel a process that is in the middle of a for() loop. What I would like is a dialog that pops up on the over the application window that simply says "Cancel". I was reading used the code from Nishant's article Tutorial - Modeless Dialogs with MFC (http://www.codeproject.com/dialog/gettingmodeless.asp#xx211427xx). I've declared my modeless dialog as a local variable in the function with the loop. In the loop I want to check to see if the Cancel button was pressed. When I enter my loop, I can't press the Cancel button. Any ideas?? Thanks in advance.
LONG CTest3431::TestKeypad()<br />
{<br />
LONG lRetVal = 0;<br />
CCancelDlg dlgCancel;<br />
<br />
dlgCancel.SetProgressText("Running keypad test...");<br />
dlgCancel.ShowWindow(SW_SHOW);<br />
....<br />
<br />
for( i=0; i<sizeof(sbKeys); i++ )<br />
{<br />
if( dlgCancel.IsOperationCancelled() )<br />
{<br />
lRetVal = -1;<br />
break;<br />
}<br />
<br />
....<br />
}<br />
<br />
Mark Donkers
A witty saying proves nothing.
-- Voltaire
|
|
|
|
|
|
That did the trick. Thanks Ravi!
MD
Mark Donkers
A witty saying proves nothing.
-- Voltaire
|
|
|
|
|
hi
i need a help in printing. in my project my window certain area i like to print not the entire client area. how can i print the data containing in the particular area on the window to printer.
thanks alot
from
venu
|
|
|
|
|
Hi guys.
I have the following question?
I know that the WM_CHAR message goes to the main window of the program but isn't it Main Frame?Yeah,yeah ... i see that this is CView but where exactly this is coded in MFC?
And if I try to "go round" Doc/View and do something like
m_pMainWnd = new CMainFrame
m_pMainWnd->ShowWindow(..)
m_PMainWnd->UpdateWindow()
who gets WM_CHAR ?
and yes .. .I'm a newbie
10x in advance
|
|
|
|
|
OK. I made a template class that is like a circular buffer but then that could take many diffferent types of variables for a 2-D type graph.
Now, I want to use declare a pointer to this in another class BUT that does not know what kind of variables it will be before hand. Is this possible? After this, when I declare the graph class lets say, I want to tell it what kind of variables the circ buffer will be. This way, it can use the variable types and how I tell it to plot or do some manuipulation.
I am not sure how even to do this. Any ideas would be greatly appreciated.
Thanks
|
|
|
|
|
This can be done, but it is no trivial task. I'll sketch a basic scheme for a very simple data structure having only two member functions called put and get . As the host class (the one using the data structure) does not know in compile-time the exact type of the structure, this has to derive from an abstract base:
struct datastruct_base
{
virtual ~datastruct_base()=0{}
virtual void put(const void* arg)=0;
virtual void get(void* arg)=0;
}; Note the argument to the functions has to be declared as raw pointers to void , since datastruct_base does not know about the actual types handled by its derived classes. A better approach could be taken using some sort of polymorphic variable like the one featured in Boost.Any[^].
Now, template classes derive from this abstract base like this:
template<typename type>
struct datastruct: public datastruct_base
{
virtual void put(const void* arg)
{
put(static_cast<const type*>(arg));
}
virtual void get(void* arg)
{
get(static_cast<type*>(arg));
}
void put(const type* arg)
{
...
}
void get(type* arg)
{
...
}
}; That's it. The host class sees the passed data structure through its base virtual class. For each instantiation of datastruct , put and get forward to non-virtual , type-specific member functions:
class host{
private:
datastruct_base* ds;
public:
void set_datastruct(datastruct_base* ds){this->ds=ds;}
void put(const void* arg){ds->put(arg);}
void get(void* arg){ds->get(arg);}
};
host hs;
datastruct<int> dsi;
hs.set(&dsi);
int i=10;
hs.put(&i);
hs.get(&i); Hope you get the idea. This is a common idiom in modern C++, with roots stemming from a relatively old technique called envelope-letter. Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello,
I must recover the privileges (user, administrator...) of the session in progress under Win2000 that it is in room or on networks.
How must one make (out of C, C++), there would have to you it an example some share.
Thank you.
Steph
|
|
|
|
|
Can you please help me .
I need to no how to change the colour of text in c++
Thanks for your help
Rich
|
|
|
|
|
What text ?
Displayed where ? How ?
Windows Application ?
Unix Application ?
Mac Application ?
Console Application ?
Say More and Answers will follow !!!
Max.
|
|
|
|
|
I have an object say myObject of some class. I do stuff with it after doing
MyObject myObject
Then after I'm done I say
myObject = NULL;
Now if I want to use myObject after this point, do I do all over again:
MyObject myObject
or can I just go ahead and do:
myOBject.Something(); without redeclaring it?
Appreciate your help,
ns
|
|
|
|
|
First this do look like CSharp, but the capital letters on NULL indicates c++.
If indeed it is c++, then you cannot assign NULL to myObject, since it is not a pointer (On the stack);
You cannot redeclare the object. If the compiler doesn't complain, then it is because there is another stack-frame.
If you want a new object, this is how you do.
first declare myObject as a pointer:
MYObject* pMyObject = NULL;
then create an instance of it:
pMyObject = new MyObject();
then delete it:
delete pMyObject;
change all the dots to reference operator:
{.} to {->}
|
|
|
|
|
You can have as many new, and delete pairs as you like.
and yes, you need to have all the calls to the object in between these operators.
GOOD LUCK!
|
|
|
|
|
no!
ns wrote:
MyObject myObject
is not a pointer ! it's on the stack. memory will be release when the declaration gets out of scope.
ns wrote:
myObject = NULL;
Should give you a compilation error/warning.
If the object is declared on the stack ( like you did ), it will be constructed when it's declared, and deconstructed when it's going out of scope. you don't have to explicitly delete it.
If the object is on the heap :
MyObject* myObject = NULL;
myObject = new MyObject;
you can delete it :
delete myObject;
myObject = NULL;
if you want to re-use it, you will need to re-new it.
Max.
|
|
|
|
|
Okay. Very good explanation. I was mistaken that I thought I saw an object being set to NULL. It had to have been a pointer like you said. Many thanks for clarifying this...
Appreciate your help,
ns
|
|
|
|
|
You may have seen a smart pointer which made you think this. A smart pointer is a class which wraps and controls a pointer, and often setting a smart pointer to NULL internally deletes the pointer and therefore does what you were after.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Precisely. This was happening with things like _RecordsetPtr which didnt have the * associated with pointers so I mistakenly thought they were actual objects, which they actually are, except they are pointer-objects.....something like that. Anyways that was exactly where I was swimming in confusion...you hit it right on the head!
Appreciate your help,
ns
|
|
|
|
|
I want to get the keyboard message from my application My application include some dialogs and forms
Thanks!
|
|
|
|
|
What sort of application is it, does it use MFC ? You ultimately want to catch WM_KEYDOWN, WM_KEYUP or WM_CHAR. You don't need MFC for this, but the class wizard will do it for you for free if you're using MFC.
You catch the message per window, not for the whole app.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|