|
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
|
|
|
|
|
Thanks! I'm trying to do CopyFile and apparently need the unicode version which allows >MAX_PATH for file path (from MSDN). But I cant find any info on this unicode version in MSDN, or an example of its usage. My current workaround is not to copy if filepath doesnt fit in max_path but thats not very friendly....
|
|
|
|
|
Hi,
In a MFC app I have a menu like :
MENU->
Show
Hide
(...)
Names->
One
Two
Exit
Names is added dynamically with the following code :
CMenu namesmenu;
namesmenu.CreatePopupMenu();
submenu -> InsertMenu(1, MF_POPUP, (UINT_PTR)namesmenu.m_hMenu, "Names");
and filled with :
namesmenu.AppendMenu(MF_STRING, ID_NAMES + i, strNames[i]);
ok, now in my CDialog derived class, to know when an added option (One, Two, etc) is selected, I have :
BOOL CReminditDlg::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
if (pHandlerInfo == NULL && nCode == CN_COMMAND)
{
/*
here I need to know how many menu items had been added, and I
don't know how to do this !
*/
}
return CDocument::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
Thanks if anyone can help me !
|
|
|
|
|
In other words, how to access a submenu of a submenu ?
|
|
|
|
|
I'm not quite sure why are you using OnCmdMsg. If you want to handle the range of command IDs, just use ON_COMMAND_RANGE in your message map.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Thanks, but the MSDN sample DYNAMENU use OnCmdMsg to handle dynamically created menus.
Anyway, how to access to the "Name" submenu ?
|
|
|
|
|
Ok I don't use ON_COMMAND_RANGE because I don't know in advance how many items I will add...
|
|
|
|
|
But there's upper limit. You won't be adding 10000 items for sure.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Ok you're right ;o)
But this isn't the problem : I try to access to the dynamically created menu :
CMenu menu;
menu.LoadMenu(ID_MENU); // load the menu
CMenu* submenu = menu.GetSubMenu(1);
CMenu* namesmenu = submenu.GetSubMenu(...);
int nItem = namesmenu.GetMenuItemCount();
but it doesn't work...
|
|
|
|
|
Have no idea how your menu looks like. Check if 'submenu' points is non-NULL. If it points to some CMenu object, then check if it's actually the submenu you're looking for - use GetMenuItemCount/GetMenuString. If you get this right, proceed to namesmenu.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Is there actually a difference between a pointer and a handle, or is it just the context of what you happen to be talking about?
BW
{insert witty/thought-provoking saying here}
|
|
|
|