|
This has got me stumped. I've got a program that draws a circle, triangle, or square depending on the item selected in a Shape menu (three sub-items: circle, triangle, square). I've got accelerators set, and they do in fact work, yet the appropriate menu sub-item letters are not underlined as they should be to let the user know that the key is an accelerator. For example the circle sub-item was defined as: &Circle\tF7
F7 and Alt C works, but the "C" in circle is not underlined. The "F7" does show up when the Shape menu is displayed. I'm using VC 2003 and this is the appropriate code in Resource.rc:
IDR_MAINFRAME ACCELERATORS
BEGIN
VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT
VK_F7, ID_SHAPE_CIRCLE, VIRTKEY, NOINVERT
VK_F9, ID_SHAPE_SQUARE, VIRTKEY, NOINVERT
VK_F8, ID_SHAPE_TRIANGLE, VIRTKEY, NOINVERT
"C", ID_SHAPE_CIRCLE, VIRTKEY, ALT, NOINVERT
"T", ID_SHAPE_TRIANGLE, VIRTKEY, ALT, NOINVERT
"S", ID_SHAPE_SQUARE, VIRTKEY, ALT, NOINVERT
END
/////////////////////////////////////
IDR_MAINFRAME MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", ID_APP_EXIT
END
POPUP "Shape"
BEGIN
MENUITEM "&Circle\tF7", ID_SHAPE_CIRCLE
MENUITEM "&Triangle\tF8", ID_SHAPE_TRIANGLE
MENUITEM "&Square\tF9", ID_SHAPE_SQUARE
END
END
///////////////////
Again, the problem is that the "C", "T" and "S" in Circle, Triangle and Square are not showing up underlined when the program is run. ???
sf
|
|
|
|
|
Are you running XP or 98?
If you are using XP, the Accelerator keys are not underlined until you press the alt key.
To disable this feature:
From the control panel click on "Display"
Click on the "Appearance" Tab
Click on the [Effects...] button
Uncheck "Hide underlined letters for keyboard navigations until I press the Alt key"
|
|
|
|
|
Hi, CDC has method to floodFill, but if I want to do double buffer, I need to use Graphics object as offscreen device... but Graphics has no floodFill method... Any suggestions???
|
|
|
|
|
|
I want to code a sdi program without document-view support(changed slightly form program appwizard generates).There are two CFormView in it,a and b;I try hard to switch between them,not to destroy one and create another,just hide one and show the another.but it doesn't function as expected.
i use two create functions in CMainFrame:onCreate()
as if (!a.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
}
if (!b.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
}
in a menu command item;
i use a.ShowWindow(SW_HIDE) and b.ShowWindow(SW_SHOW|SW_MAXIMIZE) ,but it doesn't work
can anyone help me ?
|
|
|
|
|
Hey all, any time I want to use some code that I find in an article on codeproject (or one of its competitors), it's annoying going through the process of adding it to my project.
Here is what I'm proposing:
I (and anyone else who is interested) create some helper functions in the form of a macro (.dsm) that will allow developers who submit code to this site (and other sites) to very easily create an additional macro file that will allow users to automate the insertion of the code into their project.
Does anyone know if this has already been created? Do you think that this would be a useful project? Anyone want to join me in creating some functions?
|
|
|
|
|
Sounds scary as hell to me. The best way to introduce bugs quickly into your code used to be with a quick cut and paste, but even quicker would be to get a macro to do it.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Consider a simple file in Ms Word. Let's say the file has
First Name : Last Name :
I have a program in Visual C++ that gets the first and last
name of the individual. I can use ShellExecute to execute
the word file, but how can I make the first and last name
go into the file and appear where I want them to. I prompt
the user for the information in the Visual C++ program and
move that info to the word file....somehow???
Any ideas or any web pages that would kinda of explain this?
Please, any response anyone can give me will be greatly
appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
You'll need to use Automation to run Word and change the contents of the active document. There are tons of docs on doing this, start by looking at the Office development docs, or even the Word help (if you've installed the VBA help).
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer.
-- Michael P. Butler in the Lounge
|
|
|
|
|
If you need the changes to be static and 'in' the file, then stop reading.
The quickest way would to be to use an embedded property in your doc. Then just modify the doc property and when you open the doc presto.
For example in my doc i might have the link :
{DOCPROPERTY "Category" \* MERGEFORMAT}
In explorer if i right click on the file and look at Properties-Summary I can see, and set, the Category value. I'm sure i saw a project here somewhere a year or two ago about getting/setting file properties.
|
|
|
|
|
To make this short, we're using the latest Visual Studio (.NET 2003) on Windows XP, and memory allocations are incredibly slower (takes about 12 times as long) when the executable is launched from within the debugger as compared to launched from a command line.
Specifically, I've got an example program that demonstrates this up at http://www.horningabout.com/temp/SpeedTest/ , if you want to take a look. It's just doing a loop and repeatedly allocating and freeing memory. VTune reports all of the time is being spent in RtlCompareMemoryUlong and RtlFillMemoryUlong when launched from within the debugger, while these are never called when launched from the command line. I have determined that these calls are in no way required to debug, since I can launch the program from a command line, then attach with a debugger, and then have the program continue, and it will be fast, not calling these functions.
After talking back and forth with one of the engineers on the VS team at MS, I found out that when NT creates a new process and initializes the heap, it sets some flags saying to clear the memory before allocating and after freeing it, which is what is taking all of the time. The code below is a quick workaround for anyone else experiencing this problem (note that it depends on some internal structures of the heap that I have only verified on XP):
int WasLaunchedInNTDebugger(void) {
long *data;
int ret=0;
data = HeapAlloc(GetProcessHeap(), 0, 8);
if (*data == 0xbaadf00d) {
ret=1;
}
HeapFree(GetProcessHeap(), 0, data);
return ret;
}
void disableRtlHeapChecking(HANDLE heap) {
extern HANDLE _crtheap;
if (heap == NULL)
heap = _crtheap;
if (WasLaunchedInNTDebugger()) {
assert(*((long*)heap + 4) == 0x40000061 ||
*((long*)heap + 4) == 0x40000060);
*((long*)heap + 4) &= ~0x7D030F60;
}
}
I hope this helps someone, it was a pain to figure out and fix!
|
|
|
|
|
I have created a dialog box that I use to input program settings. When I tried adding a CComboBox, however, I get debug assertation failures in afxwin2.inl. Any attempts to access the combo cause a failure. Can someone tell me what I'm doing wrong? Here's the code I'm using.
/...
// create dialog
MyWebGallerySettingsDialog settingsDlg;
settingsDlg.m_nCenterHeight = pDoc->GetCenterHeight();
settingsDlg.m_nCenterWidth = pDoc->GetCenterWidth();
settingsDlg.m_ctrlCenterStyle.SetCurSel(0); // <- this is the line causing failure
// launch the dialog
if(settingsDlg.DoModal() == IDOK)
{
/...
|
|
|
|
|
Cause your instance of combobox has not been existed yet, of cause it will crash.
Try to put
SetCurSel(0)
in your WM_INITDIALOG handler.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
In this line "settingsDlg.m_ctrlCenterStyle.SetCurSel(0);"
u r trying to use combobox object when actually it is not created ,cauz it is before DoModal statement
Write this statement
m_ctrlCenterStyle.SetCurSel(0); in the OnInitDialog member of ure dialog class , all initialization and settings of dialog controls should be done here
No Worries!
|
|
|
|
|
Hello,
I created a Regular Dll that should display a Dialog Box so that the user can enter some information. But when i call my dll using a regular c application nothing gets display to the user. I am kinda lost. I started by creating a regular dll with the option of using MFC libs using vc++ 6.0. I exported a function which calls my Dialog box class:
extern "C" __declspec(dllexport) long CallDlg()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CmcDlg dlg;
dlg.DoModal();
DWORD dw = GetLastError();
printf("failed: GetLastError returned %u\n", dw);
return 0;
}
The dlg.DoModal() function does not start anything. Here is how my dialog class:
// mcDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MFCdll.h"
#include "mcDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CmcDlg dialog
CmcDlg::CmcDlg(CWnd* pParent /*=NULL*/)
: CDialog(CmcDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CmcDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CmcDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CmcDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CmcDlg, CDialog)
//{{AFX_MSG_MAP(CmcDlg)
ON_BN_CLICKED(IDC_Add, OnAdd)
ON_BN_CLICKED(IDC_Multiply, OnMultiply)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CmcDlg message handlers
void CmcDlg::OnAdd()
{
// TODO: Add your control notification handler code here
int iVar1 = GetDlgItemInt( IDC_EDIT1 );
int iVar2 = GetDlgItemInt( IDC_EDIT2 );
int iRes = iVar1 + iVar2 ;
SetDlgItemInt( IDC_EDIT3, iRes, TRUE );
UpdateData(FALSE);
}
void CmcDlg::OnMultiply()
{
// TODO: Add your control notification handler code here
int iVar1 = GetDlgItemInt( IDC_EDIT1 );
int iVar2 = GetDlgItemInt( IDC_EDIT2 );
int iRes = iVar1 * iVar2 ;
SetDlgItemInt( IDC_EDIT3, iRes, TRUE );
UpdateData(FALSE);
}
void CmcDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void CmcDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
Anybody knows why? Thanks in advance for you help.
|
|
|
|
|
You may need to use AfxSetResourceHandle(): Did you check in debug where it fails?...
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
It fails at the point where I am calling the dlg.DoModal();
It returns -1. That's it.
|
|
|
|
|
Is there an API, or method, to create a file and lock part of it in an atomic operation?
(This has to work with a common directory on a network where the source systems don't know about each other, so Mutexes are out.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Not in the win32 api. You might be able to do this with a device driver though.
John
|
|
|
|
|
Why not create the file with "exclusive" access?
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
Why not create the file with "exclusive" access?
That would prevent read access to a portion of the file.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Joe Woodbury wrote:
That would prevent read access to a portion of the file.
Only from another process. If you are just creating the file and you want to lock it straight away then it sounds like you don't want any other process to access it anyway. Not much in it for them anyway, seeing it is empty.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
Only from another process.
Exactly.
I need to create a file and lock the whole file. I then write the header and additional data and then change the lock to cover only the additional data so only the header is readable.
During the create process, the file must be locked. Once created, all but the first 16 bytes must be locked. If I create the file, then reopen it, there are synchronization problems. A Mutex solves this on a single workstation, but not if the file is being accessed from multiple clients in a shared directory. The ugly solution is to create a guard file except there is a situation where one of the clients could be opening the file in read only mode (and the target directory is read only.)
All this could be solved by allowed a create and lock in an atomic operation. (Actually, if I could have the entire creation process as a single transaction, that would be perfect. But since the shared directory may not even be Win32, this isn't viable.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I have a file where i am getting the name from a file:
inpf.get(name,15);
How can I check if I get a name and it is true?
|
|
|
|
|
How about submitting a question that actually makes sense?
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|