|
OOps! I did what you said and it crashed....am going to see if I can see why...
|
|
|
|
|
Create the new dialog resource, give it the same name IDD_A and set the condition _NEW_INTERFACE_ (in the Properties dialog on the left panel), or whatever name you please. Then, by setting/resetting _NEW_INTERFACE_ in Project->Settings->Resources->Preprocessor definitions your program will use one or another dialog resource.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm using VS6. What properties window is this you mention?
Appreciate your help,
ns
|
|
|
|
|
Go to ResourceView on the left panel: there's a tree listing all resources you have included, right-click on that corresponding to the new dialog resource and select Properties.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I just got your response. In the meantime, I created my new dialog, and when I did ctrl W it said its a new dialog - cretae a new class or choose existing<. When i chose existing, it said okay I'm going to replace your old IDD_A with the new one IDD_B. And it did what it promised.....so I've pasted your resolution in m y hints.doc for the future.
Appreciate your help,
ns
|
|
|
|
|
If this line highlights the line in a list control:
m_mylistctrl.SetItemState( i,LVIS_SELECTED,LVIS_SELECTED );
how do I unhighlight the line i.e turn off these flags??
thanks
grahamoj.
|
|
|
|
|
m_mylistctrl.SetItemState( i,0,LVIS_SELECTED );
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
We need to put together a Visio-like visual designer app. Anyone know of a VC++ or .NET toolkit available to build this sort of application? I'm grateful for your suggestions!
|
|
|
|
|
Everybody is taking this word 4 granted - I even have a code (from my
ex-coworker) which has some of it included in a project (that I must continue) but I can't get the difference between 'Hardcoded' files & other 'normal' Visual C++ files.
So please can any1 tell me wtf( ) are these "Hardcoded files"?
Tnx!
Love is the law, love under will.
|
|
|
|
|
It depends on the context, but I'd take it to mean using a number directly in the source, where a constant could be used instead (or even read the value in from a config file, or the registry)
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Hardcoded is a very general word. Usually it means that an implementation tends to be very inflexible and designed to solve a very narrow problem instead of the more general solution.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
::fopen("c:\\temp\\out.txt", "rw");
In this example file name is hardcoded, which assumes 1.)you never want to create file anywhere else. 2.) name of the file never changes 3.) directory "C:\temp" exists on the user computer.
It is considered bad practice even for debugging purposes.
|
|
|
|
|
In my opinion the term "hardcoded" implies that a value or an algorithm can only be changed by changing the source code.
Ivor S. Sargoytchev
|
|
|
|
|
i use the words hardcoded and dynamic.. hardcoded means something can't be changed without recompiling, whereas something that is dynamic can be adjusted on the fly.
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Hi,
I have a requirement to complete, but i'm not sure how to do it. I know I'll have to use a CFormView interface. The thing is, i have to get fonts to work within this view. It's basically a listing output of some technical information. However, my boss wants it to have font & color capability. I've already ruled out using CListCtrl, as that's just a listbox basically. I've thought about CRichEditCtrl's, but that's editable by the user right? And we don't want that to be a possibility... Does anyone have any ideas?
|
|
|
|
|
|
Could you be more specific as to what to do? I'm rather new to windows programming. Thank you!
|
|
|
|
|
See MSDN article Q85518. It Shows how to set font for individual control, but you can apply that to any CWnd derivative(CFormView in your case).
|
|
|
|
|
I've searched msdn.microsoft.com all over for this "Q85518", and I can't find a darn thing. Am I looking in the wrong place?
|
|
|
|
|
Sorry, name of the article is "INFO: Correct Use of the SetFont() Function in MFC"
in case you do not have it here is the code( I hope MS will not sue me
/*
* Compiler options needed: None
*/ class CMyAboutBox : public CDialog
{
CFont m_font; public:
// Constructor -- This code assumes a dialog box
// template named "ABOUTDLG" in the application's .RC file. CMyAboutBox(CWnd* pParentWnd = NULL) :
CModalDialog("ABOUTDLG", pParentWnd) {}; BOOL OnInitDialog();
};// OnInitDialog() function -- Called after Windows creates
// the dialog box but before it is painted on the screen.BOOL CMyAboutBox::OnInitDialog()
{
LOGFONT lf; // Used to create the CFont. CDialog::OnInitDialog(); // Call default ::OnInitDialog memset(&lf, 0, sizeof(LOGFONT)); // Clear out structure.
lf.lfHeight = 20; // Request a 20-pixel-high font
strcpy(lf.lfFaceName, "Arial"); // with face name "Arial".
m_font.CreateFontIndirect(&lf); // Create the font. // Use the font to paint a control. This code assumes
// a control named IDC_TEXT1 in the dialog box.
GetDlgItem(IDC_TEXT1)->SetFont(&m_font); return TRUE;
}
|
|
|
|
|
Yea, the person working on this app before me did something like that in the OnInitialUpdate of the CFormView class.. check this out
I posted this after your initial response....
Hi,
I need some serious help setting a font in a CFormView (with an embedded CListCtrl)class. The on initial update code looks like this...
void CTextWindow::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
//size the window to the proper side that would fit the parent
CFrameWnd *pParentFrame = GetParentFrame();
pParentFrame->RecalcLayout();
ResizeParentToFit(TRUE);
//displays the window text depending on the template used to
//create an instance of this class.
if(GetDocument()->GetDocTemplate() == theApp.pOutputDocTemplate)
pParentFrame->SetWindowText("Output Window");
else
pParentFrame->SetWindowText("");
//intialize the font to be used with a constant font
font.CreateFont(14,0,0,0,0,0,0,0,0,0,0,0, FIXED_PITCH | FF_MODERN, "Courier New");
//delete all entries from the list control
m_List.DeleteAllItems();
//set up list control to contain one column
m_List.InsertColumn(0,"Text",LVCFMT_LEFT, 1600, -1);
//set a font of the list control
m_List.SetFont(&font,FALSE);
//set a boolean flag to false to indicate that no file has been loaded yet.
fFileLoaded = false;
}
Pay attention to the lines....
//intialize the font to be used with a constant font
font.CreateFont(14,0,0,0,0,0,0,0,0,0,0,0, FIXED_PITCH | FF_MODERN, "Courier New");
m_List.SetFont(&font,FALSE);
I'm trying to implement font control in this program after the initial update, but I also want to set the font before this window is created. So I'm having a lot of trouble.
I try to make a member function that looks like this.
void CTextWindow::SetScreenFont (...)
{
//same font object as before
font.CreateFont (//parameters);
m_List.SetFont (&font, FALSE);
}
I do this and I get Debug Assertion errors in the Debug configuration and crashes in the Release! Can anyone tell me how to remedy this problem and get a working font control algorithm?
Thanks,
Mike Mathers
My only guess is that a CFont object can only create a font once... but I don't know what else to do to set the font of the CListCtrl. Any ideas buddy?
|
|
|
|
|
1. tell me exactly where the assert happens
2. try font.Detach(); after each SetFont(it might create memory leak, but for now we just need it to work)
P.S. I am little bit out of date with MFC, so forgive me for guessing
|
|
|
|
|
BOOL CGdiObject::Attach(HGDIOBJ hObject)
{
ASSERT(m_hObject == NULL); // only attach once, detach on destroy
if (hObject == NULL)
return FALSE;
CHandleMap* pMap = afxMapHGDIOBJ(TRUE); // create map if not exist
ASSERT(pMap != NULL);
pMap->SetPermanent(m_hObject = hObject, this);
return TRUE;
}
It fails at ASSERT (m_hObject == NULL);
The Body of "CreateFont" looks like this...
return Attach(::CreateFont(nHeight, nWidth, nEscapement,
nOrientation, nWeight, bItalic, bUnderline, cStrikeOut,
nCharSet, nOutPrecision, nClipPrecision, nQuality,
nPitchAndFamily, lpszFacename));
When do you want me to try a font.Detach()? After each CreateFont call or after each SetFont call?
|
|
|
|
|
Is there any way of calling DLL created in C# from a C++ unmanaged application?
|
|
|
|
|
Hi all,
I was monitoring my applicaiton using the task manager for Handle creation and destructions.
I've viewed my code and where i have CreateEvent , there is CloseHandle.
plus i use GDIObject utilities to check for un-handled GDI objects and there weren't any......
what else can produce a hadnle???? how can i monitor my code for that??
can any1 help?
thanks in advanced
Yaron
Ask not what the application can do for you, ask what you can do for your application
|
|
|
|
|