|
Mike, sounds like you are asking about logging eh? There are as many ways to log as there are people to answer the question
You might consider using the OS log mechanism if that makes sense for your product. Otherwise you can do whatever you want. I've done logs with a UDP socket and a database for persistance. I've also done logging directly to disk files using XML.
You really need to consider your project specific requirements for logging. The main consideration in some projects like server side projects is to get logging working day ONE! Makes life simpler.
-pete
|
|
|
|
|
Thanks for your answer!
No, I not specifically talking about logging. I'm talking about Error Messages, which most of the time just get display via an dialog. I'm also talking about multiple languages and the importance of a unique error number.
I do application which are translated into English, Swedish, Finnish. If a user calls/emails me with an error and the error messages is in Finnish, I have no clue on what the error is, since I don't speak or read Finnish. If I have a unique error number then I just look at the Swedish error message and usually I understand it
The above scenario is one major drawback of Windows, which has all error messages translated into different languages. So I use a Swedish Windows, then I get Swedish error messages, which I have to translate into English in order to find any info about the error ...
My original question was more of how to manage/administrate these error numbers, messages and how to use then in a MFC environment.
Cheers!
Mike Eriksson
Sonork 100.21825
|
|
|
|
|
I looked around and found this http://support.microsoft.com/default.aspx?scid=kb;EN-US;231777
which shows how to make an ERD (emergency repair disk). But I dont know if this also backs up my registry.
Also while running the backup utility does one have to shut down all apps? Or can one keep working and let it do its stuff in the background? The aricle doesnt say....
Thanks
Appreciate your help,
ns
|
|
|
|
|
Not sure about Win2K, but it certainly backs up the registry in Win98.
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Hi,
I'm wondering where to get info on how to burn files on a cd. I didn't find a SDK or API or something like that.
I want to make a simple app to create and burn files on multi-session cds.
-widi
-
|
|
|
|
|
|
Thanks.
I guess I didn't find something in MSDN because I'm still using the version of '98.
|
|
|
|
|
|
|
How can I use the compiler and linker from vc6 in a batch file?
I never run the batch from inside the vc/bin folder. This results in missing c++ dll's.
example:
- folder c:\testapp
inside folder:
- test.h
- test.cpp (including test.h, windows.h, iostream.h)
- compile_link.bat
What do I have to put in compile_link.bat to compile and link these sources to a win9x DLL? (and to a win9x-app also...)
TNX
using: [VISUAL STUDIO 6.0] [WIN98/2]
|
|
|
|
|
the easiest (if you already have a VC++ .dsp project file) is:
start /w MSDEV.EXE project.dsp /MAKE "myproject - Win32 Debug" /OUT buildlog.log
make sure MSDEV and all other stuff is in your path (VC++ setup creates a vcvars32.bat somewhere that registers the environment vars...)
Either make the project folder your current directory, or specify a full path to the project file (.dsp)
Make sure you specify the correct target name behind the /MAKE command.
Advantage: it respects onn your VC++ customization and project settings (including VC++ Tools/Options/Directories, and project post build commands, etc.)
You could create a project by using the project wizard for a DLL, then add your own source files.
You can also add other options (like REBUILD to force a complete build)
Another option would be creating a MakeFile - but I've been lucky in my life to largely avoid that...
Tip: make sure the target names are distinctive. I had one case, with darget names
"foo - Win32 Release" and "foo - Win32 Release ATL", where, upon specifying /MAKE "foo - Win32 Release" it would build the wrong target. renaming the first target to "foo - Win32 Release MFC", and specyfing this in the make command did fix it.
Nur wer feige ist tötet Liebe durch das Wort allein [sighist] | [Agile Programming] [doxygen] If you look for evil in me you will find it whether it's there or not.
|
|
|
|
|
I have nothing, no dsp.., except the source files (*.cpp) and header files (*.h)
But vcvars32.bat was the file what I was looking for. I copied that file to my batch folder and added a call to lc at the end, including the source folder. It worked fine
tnx
using: [VISUAL STUDIO 6.0] [WIN98/2]
|
|
|
|
|
Hello,
I have a tree view in a sdi app.. After a short period of time of extensive use my tree view turns black in color and if you were to open internet explorer etc none of the pictures show until my application is closed.. I have a feeling its a GDI leak in my OnPaint function.. This problem only happens on 9x machines and unfortunately there is no way to look at the GDI resources on 9x (that I know of).. Here’s my OnPaint function, anyone see anything wrong?
void CMyTreeView::OnPaint()
{
CPaintDC dc(this);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CRect rcClip, rcClient;
dc.GetClipBox(&rcClip);
GetClientRect(&rcClient);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height());
memDC.SelectObject(&bitmap);
CRgn rgn;
rgn.CreateRectRgnIndirect(&rcClip);
memDC.SelectClipRgn(&rgn);
rgn.DeleteObject();
CWnd::DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, 0);
HTREEITEM hItem = GetTreeCtrl().GetFirstVisibleItem();
int n = GetTreeCtrl().GetVisibleCount()+1;
while(hItem && n--)
{
CRect rect;
UINT selflag = TVIS_DROPHILITED | TVIS_SELECTED;
Color_Font cf;
if (!(GetTreeCtrl().GetItemState(hItem, selflag) & selflag)
&& m_mapColorFont.Lookup(hItem, cf))
{
CFont *pFontDC;
CFont fontDC;
LOGFONT logfont;
if(cf.logfont.lfFaceName[0] != '\0')
logfont = cf.logfont;
else
{
CFont *pFont = GetFont();
pFont->GetLogFont(&logfont);
}
if(GetItemBold(hItem))
logfont.lfWeight = 700;
fontDC.CreateFontIndirect(&logfont);
pFontDC = memDC.SelectObject(&fontDC);
if(cf.color != (COLORREF)-1)
memDC.SetTextColor(cf.color);
CString sItem = GetTreeCtrl().GetItemText(hItem);
GetTreeCtrl().GetItemRect(hItem, &rect, TRUE);
memDC.SetBkColor(GetSysColor(COLOR_WINDOW));
memDC.TextOut(rect.left+2, rect.top+1, sItem);
memDC.SelectObject(pFontDC);
}
hItem = GetTreeCtrl().GetNextVisibleItem(hItem);
}
dc.BitBlt(rcClip.left, rcClip.top, rcClip.Width(), rcClip.Height(),
&memDC,rcClip.left, rcClip.top, SRCCOPY);
bitmap.DeleteObject();
memDC.DeleteDC();
}
Thanks,
Rob
|
|
|
|
|
You never select anything OUT of your DC s.
That is, the GDI objects remain there, even if their handles (contained in the C++ objects) are gone.
The right sequence (as taken from the Prosise-book) is
pGDIObject* pOldObject = myDC.SelectObject(pMyObject);
..use myDC..
myDC.SelectObject(pOldObject);
pMyObject.DeleteObject();
myDC.DeleteDC(); This way you can be sure that all of your GDI objcets can be be destroyed when its variables go out of scope.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
use your example instead of the following?
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height());
memDC.SelectObject(&bitmap);
|
|
|
|
|
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height());
CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);
.
.
.
memDC.SelectObject(pOldBitmap);
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
|
CGDIObject* works with any GDI Object:
The CGdiObject class provides a base class for various
kinds of Windows graphics device interface (GDI)
objects such as bitmaps, regions, brushes,
pens, palettes, and fonts. <small>from MSDN</small>
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks for all your help!!
Rob
|
|
|
|
|
Instead of having to worry about the SelectObject() calls, you can also do:
dc.SaveDC(); // save state of DC
....
dc.RestoreDC(-1); // restore state of DC (i.e. remove all selected objects in between)
dc.DeleteDC();
delete GDI objects.
Roger Allen
Sonork 100.10016
WHats brown and sticky?
A stick or some smelly stuff!
|
|
|
|
|
Thank you - this might make things cleaner sometimes.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
I've created a DLL from a class of mine where i use two std::vector<> members to store something. My problem is that when i insert an element on the vector, the first operation on the vector (clear it, read the first element,etc) cause an error on the heap:
File: dbgheap.c
Line: 1044
Expression: _CrtIsValidHeapPointer(pUserData)
HEAP[Print.exe]: Invalid Address specified to RtlValidateHeap( 28d0000, 28e3bd0 )
Using the class inside the program works well. It's a problem of the STL, something to include in the DLL compiling options?
|
|
|
|
|
Gian wrote:
It's a problem of the STL, something to include in the DLL compiling options?
It sounds more like it's a DLL-boundary issue with whatever chunk of memory you are trying to push onto the vector.
Perhaps some sample code would help.
-pete
|
|
|
|
|
my dll header is
#ifndef LFONTRENDERER_H
#define LFONTRENDERER_H
//--------------------------------------------------
# define GFONT_API __declspec(dllexport)
#include <string>
#include <vector>
#ifdef _WIN32
#include <windows.h>
#endif // _WIN32
#include <gl gl.h="">
//--------------------------------------------------
typedef unsigned int uint;
typedef unsigned char byte;
#define DEFAULT_HEIGHT 99999
struct LCharCoords
{
GLfloat left;
GLfloat top;
GLfloat right;
GLfloat bottom;
bool enabled;
float widthFactor;
};
struct LFont
{
std::string name;
GLuint textureId;
uint defaultHeight;
uint height;
float widthScale;
bool italic;
GLfloat angle;
GLfloat r, g, b;
LCharCoords chars[256];
};
struct LStringData
{
std::string str;
uint font; // the font to be used
uint height; // the height of the font
GLfloat r, g, b; // the color
GLfloat angle; // the rotation angle
GLfloat x, y; // the position
float widthScale; // width scale
bool italic; // true if the font is italic
};
//--------------------------------------------------
class GFONT_API LFontRenderer
{
public:
// default constructor, initializes the object
LFontRenderer();
// the destructor, automatically called by delete
virtual ~LFontRenderer();
// returns the number of fonts loaded
uint GetFontCount();
// returns the name of the given font, index _must_ be smaller than GetFontCount()
const std::string& GetFontName(uint index);
// sets the active font, this function is also available in a version that takes the index as parameter
void SetActiveFont(const std::string& name);
// sets the active font, this function is also available in a version that takes the name
// of the font as parameter
void SetActiveFont(uint index);
// returns the index of the active font, throws an exception if no fonts are loaded
uint GetActiveFont();
// this function loads a font from a file and adds it to the list of fonts it returns the index of
// the new font. The font name paramater is a name for the font that can be used with
// SetActiveFont() etc.
uint LoadFont(const std::string& fontname, const std::string& filename);
// removes all fonts and clears any memory allocated
void Clear();
// sets the height of the current font
void SetHeight(uint height);
// sets the color of the active font
void SetColor(GLfloat red, GLfloat green, GLfloat blue);
// returns teh height of the active font
uint GetHeight();
// call this to get the color of the active font
void GetColor(GLfloat &red, GLfloat &green, GLfloat &blue);
// call thos method to output a string
void StringOut(float x, float y, const std::string &string);
// this method draws all the strings
void Draw();
// this methods sets the width scale of the active font
void SetWidthScale(float scale);
// this method returns the width scale of the active font
float GetWidthScale();
// this method sets the rotation angle for the active font
void SetRotation(float angle);
// this method returns the rotation angle for the active font
float GetRotation();
// this function is used to set either the active font should be italic or not
void SetItalic(bool value);
// this function returns true if the active font is italic
bool GetItalic();
// this function returns the width of the string. font metrics of the active font
// are used
uint GetStringWidth(const std::string &string);
protected:
// used internally
uint m_strCount;
// the index of the active font
uint m_activeFont;
// the array of fonts
std::vector<lfont> m_fonts;
// the strings to be rendered
std::vector<lstringdata> m_strings;
// the size of the viewport
uint m_viewTop;
uint m_viewLeft;
uint m_viewWidth;
uint m_viewHeight;
#ifdef GL_VERSION_1_3
// used internally, the number of supported texture units;
uint m_textureUnits;
#endif // GL_VERSION_1_3
};
//--------------------------------------------------
#endif // LFONTRENDERER_H
|
|
|
|
|
in
// the array of fonts
std::vector m_fonts;
// the strings to be rendered
std::vector m_strings;
the first is the template of LFont and the second of LStringData (the < and > are missing in the post)
|
|
|
|
|