|
Going owner-draw and setting CtlType won't take you anywhere; CtlType is set by Windows.
Do you want to create a column of buttons in your list control?
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Yes, i want one column of the control to have buttons. Actually, my aim is to make the user insert rows and the button will be created at runtime. But i don't know how to create unique IDs at runtime and how to handle messages for the new buttons. This is a further step but if you have any suggestions on this problem too, i would love to hear it.
For placing button in list, i found a way like below:
Adding the following code in OnPaint or OnCreate function does it:
CRect itemRect;
GetSubItemRect( 0, 0, LVIR_LABEL, itemRect );
CTeamButton *buttonx = new CTeamButton;
buttonx->Create( "Test", WS_CHILD|WS_VISIBLE, itemRect, this, 12345 );
But it doesn't seem to be a solid and gentle way. For example, when you resize the columns the buttons' size doesn't change. It would get worse when sorting takes place. So i can't count on it. Is there any subtle way to achieve this?
Thanks.
|
|
|
|
|
MightyThor wrote:
Is there any subtle way to achieve this?
I'm afraid not. You may consider switching to grid control instead, especially if you plan to add editing capabilities.
http://www.codeproject.com/miscctrl/gridctrl.asp[^]
If you want to stay with CListCtrl, I think it's better to give up 'real' buttons and simulate them with custom-draw or owner-draw.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
I already checked grid control and it's a magnificent work, but the reason i'm trying to build my own component is mainly for self-education, so i better keep digging this custom-draw thing.
Thanks for your interest.
|
|
|
|
|
What's the minimal windowstyle to be used with CreateWindow()?
If I use WS_POPUP, the window doesn't show up.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
|
|
|
|
|
never mind, i forgot the width and height
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
|
|
|
|
|
Okay. I n many places I have stuff like:
m_FieldHolder = new CString [m_numFields ];
if the m_FieldHolder comes back as null, I will surely crash. This is in a function of a class, lets say. SO I of course can say:
if( m_FieldHolder)
{...
}
but what if its coming back as NULL? I will surely crash if I skip the code its supposed to do when not NULL. SO at this point, from the function in my class, how do I handle things? It would be nice to call a common global function each time new failed, but then do I exit? If I dont I cant predict what would happen since I have a zillion new , but in no case have I dealt with if its NULL then do what? I suppose I could pass info into my global NewFAilure() that would tell it which new it was that failed.
Ideas?
Thanks,
ns
|
|
|
|
|
ns wrote:
Ideas?
check everywhere. return error codes from all your functions, test the error codes and react accordingly. alternately, you can use C++ exception handing (thorw, try, catch). but, either way, you have to test and you have to handle error conditions.
IMO, programming is 25% implementing the task at hand and 75% watching for things that can go wrong. nothing infuriates a user more than unexpected failures. imagine if IE crased every time it found a JPG it didn't like (bad example, it already does that)
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
_set_new_handler
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I agree with Chris' comment. Your code needs to test each point of failure and react accordingly. Basically, when a function fails, it returns with a failure code to the calling function, ad infinitum, until the top level caller is reached.
I'd just like to reiterate that you shouldn't be doing stuff like
if (m_FieldHolder) {
...
} Instead, do
if (m_FieldHolder != NULL) {
...
} Just my 2c worth!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
ns wrote:
if( m_FieldHolder)
Actually, that's incorrect. MFC overrides operator new and if it fails, it throws a CMemoryException . So you need to wrap your allocations in try /catch blocks and handle that exception.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
So if I already have a try-catch for COM errors in my code and I do a new in the try, I should add another catch?
Like
catch(CMemoryException *e)
{
}
Is the e coming in from the system?
Thanks,
ns
|
|
|
|
|
|
Hi,
I have a number of Icons downloaded from the internet.
Now i want to put the selected icons into my toolbar.
How can i do?
Thanks in advance!
chen
|
|
|
|
|
I'm looking for a component/s that acts like the left pane in Visio 2000. Each "sub-folder" must be dockable and the folders must be "foldable" (like in Visio 2000).
Does anyone have any idea ... ?
Yeali
|
|
|
|
|
What you are looking for is present on code project itself! go to libraries and projects section and download the MFC GUI Extesion library by Fransico Campos. This one's got an excellent Visio component.
|
|
|
|
|
Does anyone know of a good statistics package for C++ (preferably free/OpenSource). I'm translating a Microsoft Excel workbook full of macros into a stand-alone MFC App, and I'm having trouble finding an adequate solution to the Excel functions of LOGINV, BETAINV, etc.
Any help is always greatly appreciated.
|
|
|
|
|
Hi everybody,
I have developed an IE extension that will popup an HTML div layer with lots of information once I move the mouse cursor over a word/string in a web page document.
Now, this is restricted to only work in IE. I want the same functionality but system wide. I know there is software that can do this; that is, point the mouse on ANY string (besides the ones that are images) on the screen and voila, a nice little box appear next to the word with translations and other nice information about the word.
My question:
How can I retrieve the string beneath the mouse pointer, no matter where and in which application the mouse cursor is placed...?
I've heard of some OCR programs that can do this but I don't want that now; maybe as a next step to implement popups on images as well.
Please, if you do know anything about this, don't hesitate to mail!!!
Thx!!!
/Tommy
|
|
|
|
|
I'm afraid that OCR is going to be your only answer if you want *any* text, since the text gets rendered by the App to screen, and therefore may not even exist as a literal string in memory when you try and grab it.
It might be possible to somehow add a system hook to grab text that can be copied to the clipboard, but that's only going to be a tiny subset of the text on screen
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Look at the Active Accessibility API (IAccessible etc) for a good start. Its not easy to use, but provides a good lot more information on screen items.
int x=1, y=5;
x^=y^=x^=y;
<a href="http://www.codeproject.com/tips/StupidXORTrick.asp" target="_blank">ClickHereForHelp();</a>
|
|
|
|
|
Is this counted as a number of bytes? Or the number of characters? Where is it defined so that I can find its value?
Thanks,
ns
|
|
|
|
|
#define MAX_PATH 260
in windef.h
(try searching your VC++ installation folder!)
it's used as the number of elements in a character array.
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
Thanks. I'll remember that. I just tried the msdn and it didnt say much. One thing: do you think its big enough to hold an random path to a file on some users machine, in general? I'm using filecopy and will know the destination and source interactively, so cant predict pathlength. Would you error trap this just in case, Or is it safe to assume that paths will fit into 260? I'm not sure what the smart thing to do is, in this case...
thanks,
ns
|
|
|
|
|
yes, i'd make sure things fit. (measure strings first).
and when at all possible, i try to use dynamic strings like CString, std::string, etc. and i only measure when i run up against a non-dynamic string (char buf[MAX_PATH]).
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
Actually, it's _MAX_PATH , which is the OS specific max length of a fully qualified filespec. If my memory serves me right, it's defined in stdlib.h .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|