|
How can I put a main menu created in Resource in a dialog box? And how can I crate the menu handler codes for the sub menu items?
Thank you all
|
|
|
|
|
1) Right-click on dialog template, select "Properties". If Properties dialog select menu ID from Menu combo box.
2) To handle menu items use MFC Class Wizard. If you don't use MFC, handle WM_COMMAND message.
|
|
|
|
|
If you built your menu in the resource editor of VS, you can add it in the properties of the main dialog. Or:
Add a protected member:
CMenu m_Menu;
then in OnInitDialog()
this->m_Menu.LoadMenu(IDR_MENU1);
this->m_Menu.LoadToolbar(IDR_TOOLBAR1);
<code>
this->SetMenu(&m_menu);
to handle the clicks, use class wizard and find the ID of the menu Item and handle it.
That should get you going.
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Thank you very much.
But I have something to tell you that You used LoadToolbar method for a CMenu object. This causes an error. I think you wanted to see a toolbar (menubar) around the menu created.
Another thing:
I can't see the mnemonics of the menu items using this solution.
And finaly
Can I transfer the description (prompt) text of current menu item user selected into a status bar?
|
|
|
|
|
GurGur wrote:
But I have something to tell you that You used LoadToolbar method for a CMenu object. This causes an error. I think you wanted to see a toolbar (menubar) around the menu created.
Sorry, I'm so used to using BCMenu [^] I forgot. It's really all I use anymore .
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Example: LoadTypeLib(...)
QuickInfo - from MSDN:
Windows NT: Use version 3.1 and later.
Windows: Use Windows 95 and later.
Header: Declared in oleauto.h.
Import Library: Link with oleaut32.lib.
QUESTION 1:
To use LoadTypeLib from a client application, do ALL of the following:
(1) Project>Add To Project>Files>oleaut32.lib
(2) #import "oleaut32.lib" (Should I include the full path?)
(3) #include "oleauto.h"
QUESTION 2:
Also, if I dont #include "windows.h", there's a whole bunch of compile time errors... why?
norm
|
|
|
|
|
Question 1:
You don't need steps 1 and 2, Instead select "Settings" from VC's "Project menu", pick "All Configurations" from the "Settings For:" drop down, select the "Link" tab, and enter oleauth32.lib into the "Object/library modules:" text box.
Question 2:
If you're using code that relies on stuff defined in windows.h then it won't work if you don't include it
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
thanks for the feedback, but how am i supposed to know that it needs windows.h if MSDN doesnt tell u that it does?
QuickInfo - from MSDN:
Windows NT: Use version 3.1 and later.
Windows: Use Windows 95 and later.
Header: Declared in oleauto.h.
Import Library: Link with oleaut32.lib.
i know only from my experience...
norm
|
|
|
|
|
my problem is I try to create a file which name is
not english in english OS.
I use GetOpenFileName() to let user select a file,
and use the returned string (ofn.lpstrfile)pass into
CreateFile() as auguemnt.
but failed.
so could someone help to solve such problem..??
as I know only windows explorer in win 2K/XP
could support different language's file name.
but still can't create file in win 2K/XP using the
procedure described above.
thanks.
|
|
|
|
|
Are you using CFileDialog? I don't think language would matter. I get a filename like this:
void MyApp::OnBrowse()
{
try
{
CFileDialog fd(false,_T("ext"), _T("*.ext"));
if(fd.DoModal() == IDOK)
this->m_szFilename = fd.GetPathName();
return;
}
catch(...)
{
AfxMessageBox("Error browsing for file!");
<code> </code>
return;
}
}
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
please
how to call MS Word Commands using DDE in Visual c++
such as [FileSave], [EndOfDoc] I managed these.
help me with the following commands please:
[EndOfLine]
create Frames
Change Font size and Colors.
|
|
|
|
|
#import "...mso9.dll" no_namespace
void dump_com_error(_com_error &e)
{
_tprintf(_T("Oops - hit an error!\n"));
_tprintf(_T("\tCode = %08lx\n"), e.Error());
_tprintf(_T("\tCode meaning = %s\n"), e.ErrorMessage());
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
_tprintf(_T("\tSource = %s\n"), (LPCTSTR) bstrSource);
_tprintf(_T("\tDescription = %s\n"), (LPCTSTR) bstrDescription);
}
struct StartUpCom
{
StartUpCom() { CoInitialize(NULL); }
~StartUpCom() { CoUninitialize(); }
} _global_com_inst;
void main()
{
IApplicationPtr pApp;
try
{
try
{
// Start up existing winmsg, if available
HRESULT hr = pApp.GetActiveObject(L"word.Application");
if (FAILED(hr))
_com_issue_error(hr);
}
catch(_com_error& e)
{
dump_com_error(e);
_tprintf(_T("NOTE: This is not a TRUE error!!\n"));
_tprintf(_T("Starting up word.exe...........\n"));
try
{
// Start up fresh instance of word
HRESULT hr = pApp.CreateInstance(L"word.Application", NULL, CLSCTX_LOCAL_SERVER);
if (FAILED(hr))
_com_issue_error(hr);
}
catch(_com_error& e)
{
dump_com_error(e);
}
}
//use pApp;
}
catch(_com_error& e)
{
dump_com_error(e);
}
}
//HKEY_CLASSES_ROOT\CLSID\{FB7FDAE2-89B8-11CF-9BE8-00A0C90A63
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
Dear Ladies & Gentlemen,
A small help request from a newbie...
I would like to create a small 32 bit prog that deletes all zero byte files in the Windows directory with the extension ".tmp". The other thing is that it should not pop up a dialog frame while it is working. It should run hidden every time the computer is restarted.
I´ll guess I can enter the program path in the Windows registry key "Runservices", so it will execute on every Windows startup.
* Is there any codesample here at the board that deletes zero byte files, that I can study?
* How do I set up VC++ to make a "hidden prog" that will not bring up any screen dialogs?
Best regards,
Peter
|
|
|
|
|
1. you can just check the file size to determine zero-size files (see CFile::GetStatus, or _fstat)
2. start a new project, but make a Console app, not an MFC AppWizard app. you can use MFC, if you want. no UI at all.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
Thanx Chris!
I´ll guess that I have to search and make a list or table of all zero byte files found in the directory, in order to then delete them.
Do you have a nice codesample that shows how to do it?
/Peter
|
|
|
|
|
You don't need a list, just use the sample code in MSDN to iterate through files and then delete them as you find them, unless you want to offer a user prompt.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
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
|
|
|
|
|
Thank you Christian, for your seuggestion.
I will try that!
|
|
|
|
|
how to set the pane frame size explicitly depending on the screen size?
|
|
|
|
|
Use CSplitterWnd::SetRowInfo & SetColumInfo to set the minimun and
required sizes for the pane.
|
|
|
|
|
how (where)to code a sw to be portable across win 95,98 and 2000.
will any compromises have to be made wrt UI or normal stl logic?
Ross
|
|
|
|
|
there won't be any STL issues, as STL is a compiler thing, not an OS thing.
i've never had any UI issues. just stick to the basics and you'll be fine.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
what about the memory allocations and mapping modes.I heard the approach is different between 95/98 and NT.isn't 2000 similar to NT.
Ross
|
|
|
|
|
If you write code using VC6, it will run fine on W95/98/etc. It's only if you use features that were introduced later that you run into problems. I've never see any problems with memory allocations or mapping modes. Mapping to what ?
W2000 is NT5. It was MEANT to be be what XP is, a merging of the two streams. Win ME was and is an abortion.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
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
|
|
|
|
|
|
It's probable that NT offered different mapping modes, GDI changes a lot between releases of windows, but do you really think they would release a new version of windows that does not run all the software written before for previous versions ? Who would buy it ?
Don't install any SDK's if you're targeting W95, otherwise just read the docs and test often on your lowest platform. Testing on the others does not hurt, but it's wrong to think that you need to write two versions or do some magic, I think everything I ever wrote has run under W98 and the NT stream, unless I used features that limited it to W2000+.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
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
|
|
|
|