|
I thought what I'd do is to keep a copy of the latest accelerator table in the application object, and override the CDocument virtual GetDefaultAccelerator() method, returning the application's accelerator table, which will then be used by the CFrameWnd instead of the default. It's a bit of a hack, since as you noted, there's no point in storing an accelerator table in each document, but it allows easy reversion to the default (return NULL in the overridden GetDefaultAccelerator() method), and simplifies the management of the user-modified accelerator. I'll give it a try with a simple Hello World application....
|
|
|
|
|
I have an ActiveX control that is a dialog with various other child controls. When the dialog starts up, no control appears to have focus (I haven't explicitly given any child the focus). If I hit a key before giving a child control the focus (via a mouse click), I hang. This is the MFC loop I'm hanging in:
pWnd = pWndStart = _AfxGetChildControl(pWndDlg, pWnd);
while (TRUE)
{
pWnd = _AfxNextControl(pWndDlg, pWnd, CWP_SKIPINVISIBLE | CWP_SKIPDISABLED);
if (COccManager::IsMatchingMnemonic(pWnd, lpMsg))
break;
if (pWnd == pWndStart)
return NULL;
}
Obviously this loop is checking all child controls for a mnemonic that matches the pressed key. If it finds the control with the matching mnemonic, or loops through all of the controls without a match, it returns.
My problem is it never finds a match (whether I hit a matching key or not) and pWnd never equals pWndStart inside the loop.
I've checked my dialog for duplicate mnemonics (though that shouldn't cause this problem).
I'm running out of ideas. Any thoughts?
Thanks!
NOTE: I'm also not getting control Tabbing behavior. I've set my tab order but the Tab key does nothing. I'm thinking these problems are related?
-Ian
|
|
|
|
|
Hello,
I have a question about expanding CTreeCtrl items. What I first do is populate a tree like this:
void CMain:oDrive(const CString& str)
{
local = true;
m_tmain.DeleteAllItems();
CString cstr = _T(str);
TV_INSERTSTRUCT root = {0};
::ZeroMemory(&root, sizeof(TV_INSERTSTRUCT));
root.hParent = NULL;
root.hInsertAfter = TVI_LAST;
root.item.iImage = 1;
root.item.iSelectedImage = 1;
root.item.pszText = (LPTSTR)(LPCTSTR)cstr;
root.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
HTREEITEM root_item = m_tmain.InsertItem(&root);
TV_INSERTSTRUCT tvstruct;
CFileFind find;
BOOL bDir = FALSE;
bool cDir = false;
BOOL bContinue = find.FindFile(cstr + _T("\\") + _T("*.*"), 0);
tvstruct.hParent = root_item;
CString strFileName;
while (bContinue)
{
bContinue = find.FindNextFile();
strFileName = find.GetFileName();
if (find.IsDirectory())
{
bDir = TRUE;
cDir = true;
tvstruct.hParent = NULL;
tvstruct.item.iImage = 0;
tvstruct.item.iSelectedImage = 0;
tvstruct.item.pszText = (LPTSTR)(LPCTSTR)strFileName;
tvstruct.hInsertAfter = TVI_LAST;
tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
HTREEITEM hThisItem = m_tmain.InsertItem(&tvstruct);
tvstruct.hParent = hThisItem;
m_tmain.InsertItem(&tvstruct);
}
else
{
tvstruct.item.iImage = 2;
tvstruct.item.iSelectedImage = 2;
tvstruct.hParent = NULL;
tvstruct.item.pszText = (LPTSTR)(LPCTSTR)strFileName;
tvstruct.hInsertAfter = TVI_LAST;
tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
m_tmain.InsertItem(&tvstruct);
}
}
find.Close();
}
This works fine and the tree gets populated with right items. However, when I try to expand a directory by clicking on a + Nothing happens. What I first trying to do is just get a directory name. This is my function that is trying to get a directory name:
void CMain::OnTree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
HTREEITEM hIT = pNMTreeView->itemNew.hItem;
CString path;
if (pNMTreeView->hdr.code == TVN_ITEMEXPANDING)
{MessageBox("Expanding");}
path = m_tmain.GetItemText(hIT);
while (true)
{
hIT = m_tmain.GetParentItem(hIT);
if (hIT == NULL)
break;
path = m_tmain.GetItemText(hIT) + _T("\\") + path;
}
path += _T("\\*.*");
MessageBox(path);
*pResult = 0;
}
The MessageBox only shows *.* and I can't get a directory name from m_tmain.GetItemText(hIT). Does anybody know what the problem is here? It is necessary to get a directory name to pass that variable to ExploreDirectory(CString some_directory) function. Please help.
Thank you,
Victor.
|
|
|
|
|
vi has a key that will convert a character from lower case to upper case, by holding down that hot key you can convert a whole string of characters like that. Does VC++ 6.0 IDE have that kind of shortcut key? It would be handy to highlight some literal text, hit a key and convert it to upper-case.
|
|
|
|
|
|
Thanks for the suggestion, but it doesn't work for me.
|
|
|
|
|
look in the Edit menu, in the Advanced section. on my installation, it's Ctrl-shift-U. maybe you've configured your's differently.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Thanks. I never realized that existed!
|
|
|
|
|
I started with coding in C# now I want to learn c++.
My Question is: Is there a visual environment for making window applications like in c# with the Visual Studio .NET??
I don't want those MDI window apps!
I know with .NET Studio and visual studio 6 I can make dialog based window apps, but only with MFC.
And in Dev-C++ there's no visual possibility to make windows.
How do all you guys make your window apps? By testing coordinate by coordinate for each control, until they're arranged correctly?
It's so simple in c#...
P.S. I want to be independent from the .NET framework, too. (i.e. no managed c++ in .NET!)
|
|
|
|
|
The equivalent of the C# "forms" in MFC would be the CFormView, you create it, and use a dialog resource to create the form; the same way you create a dialog.
the visual studio comes with a resource editor to create the menus, toolbars, dialogs, ... but it does not really come with a "view" editor.
I don't think there is a 1 to 1 equivalent with MFC ( and the visual studio IDE ) to do Windows Forms.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I use VC 6.0 and MFC to make windows. You use the resource editor to position your controls in the window. When you create your project you can either use Dialog type application or SDI/MDI application and derrive your CView class from CFormView and you can place controls in it like you would with a dialog box.
|
|
|
|
|
well, so i'll have to get used to the MFC, but how do I check the window message like this:
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
case WM_PAINT:
// I can't find that in dialog based window apps in mfc
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
|
|
|
|
|
This is purely win32 programming. That means without the MFC. The MFC are in fact just wrapper classes around the Win32 API. You can still use the resource editor with a win32 project.
For Dev-C++, you can use an external resource editor (there are some free on the web, just google for that) and add the resource in your project.
But Win32 programming is not that easy because you will need to manage everything by yourself (creation of the window, managing the message queue, ...)
|
|
|
|
|
That's what I meant: purely win32 programming without the MFC,
"you will need to manage everything by yourself (creation of the window, managing the message queue, ...) "
that's the interesting part in c++, isn't it?
Then I'm gonna search for resource editors to make windows, thank you very much!
|
|
|
|
|
Opa Knack wrote:
that's the interesting part in c++, isn't it?
Yes this is interesting but it take some time to feel confortable with that . But if this is not a problem for you, then that's great because you will learn a lot about how a windows program work.
|
|
|
|
|
This was the first book I read on Windows development. My first resource editor was...Notepad. Go forth and learn!
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
good ol' petzhold
|
|
|
|
|
Opa Knack wrote:
I know with .NET Studio and visual studio 6 I can make dialog based window apps, but only with MFC.
MFC has no bearing on whether an application is dialog-based or not.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I posted this late last Friday, so over the weekend the answer has gotten lost in the depths of The Code Project. I was looking to make my program not resizable, and one suggestion I got was that I could remove teh WS_THICKFRAME style, but could I please get some advice on how to do this?
|
|
|
|
|
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Something seems to be wrong with the link
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Use CWnd's ModifyStyle[^].
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Hey guys
I.ve been trying to develop a tiff viewer for quite some time now but havent been able to,
can anyone help me out? gauravmalhotra18@gmail.com
Gaurav
|
|
|
|
|
|
I am trying to set up linked list (MC++ Array List) with a loop adding 381 instances of the object. I would like each instance of the object to have a unique object name. I have tried adding the space number (i) onto a string but it will not let me use it as the object name.
Also When i run the below code it will set up 381 object, however the space from set_Space() is all the same at 381 on each instance. I thought that when i put each object into the array list it was unique but somehow they are all linked together. Thanks in advance.
<br />
void Resident::setupMaster()<br />
{<br />
ArrayList *al = new ArrayList();<br />
Resident* resident = new Resident();<br />
<br />
for(int i=0; i<=381; i++)<br />
{<br />
resident->set_Space(i);<br />
al->Add(entry);<br />
}<br />
|
|
|
|