|
This is possible but only if you are willing to do the drawing and measuring of the rows yourself. Check out this article[^].
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Hi,
I'm having problems finding a good function to find a temporary folder. I've used GetTempPath() and it returned something along the lines of
C:\Docume~1/Jack/Local~1/Temp
and that's fine but I can't use it because after copying some files into this dir I also have to set a registry key regarding one of the files and it doesn't work right because of the ~ in the name. If someone could help me figure out how to do one of the following I'd appreciate it a lot, I'm getting tired of trying to find a solution to this annoying problem. It only has to work on XP.
1. A way to get the FULL path of a users temp folder without ~
-or-
2. A way to convert a path with ~ to a FULL path without ~
Thanks,
Martin
|
|
|
|
|
Perhaps you should have a look at the function
DWORD GetFullPathName(
LPCTSTR lpFileName,
DWORD nBufferLength,
LPTSTR lpBuffer,
LPTSTR *lpFilePart
);
in MSDN.
-Dominik
|
|
|
|
|
I would suggest that if a ~ is breaking your code, then fix whatever that bug is.
But you can use GetLongPathName() if you're using 98+ or 2000+.
--Mike--
"alyson hannigan is so cute it's crazy" -- Googlism
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
GetLongPathName() only works on 98+.
GetFullPathName() works on 95 too.
So why not using GetFullPathName?
-Dominik
|
|
|
|
|
Dominik Reichl wrote:
So why not using GetFullPathName?
Because GetFullPathName() doesn't do what the original poster wanted to do. From MSDN:GetFullPathName does no conversion of the specified file name, lpFileName. If the specified file name exists, you can use GetLongPathName and GetShortPathName to convert to long and short path names, respectively. So MSDN itself says you have to use other functions to convert between the LFN and SFN names.
--Mike--
"alyson hannigan is so cute it's crazy" -- Googlism
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
|
if i alloc menory (i.e. by new) but forget to free (by delete), are there some tools or functions which can check the problem and info me details( i.e. size, address of memory occupied).
if yes, could they check both before and after my app exits?
checking free memory size is not good enough because it doesn't know if my app causes problem (maybe caused by other programs).
thx
includeh10
|
|
|
|
|
MFC programs seem to have this built-in by using custom new() and delete() functions.
You could do that too.
|
|
|
|
|
i need checking, bot building.
includeh10
|
|
|
|
|
|
It's really not MFC that have it, it just use some of the CRT debugging functions
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
You can hook memory allocations in the runtime library via something like the following (I pulled this out of some software of mine):
FILE *_AllocHookFile = NULL;
bool _AllocHookFileClose = false;
void _AllocHookInitialize()
{
_AllocHookFile = fopen("AllocHook.Log","w");
_CrtSetAllocHook(_AllocHook);
}
void _AllocHookTerminate()
{
_AllocHookFileClose = true;
if (_AllocHookFile != NULL) {
fclose(_AllocHookFile);
_AllocHookFile = NULL;
}
}
int _AllocHook(int allocType,
void *userData,
size_t size,
int blockType,
long requestNumber,
const unsigned char *filename,
int lineNumber)
{
if (requestNumber == 87) DebugBreak();
if (blockType == _CRT_BLOCK) return TRUE;
if (_AllocHookFileClose) return TRUE;
long _request = requestNumber;
char _allocType = '?';
char _blockType = '?';
int _size = size;
char *_filename = (char *)filename;
int _line = lineNumber;
switch (allocType) {
case _HOOK_ALLOC: _allocType = 'A'; break;
case _HOOK_REALLOC: _allocType = 'R'; break;
case _HOOK_FREE: _allocType = 'F'; break;
}
switch (blockType) {
case _FREE_BLOCK: _blockType = 'F'; break;
case _NORMAL_BLOCK: _blockType = 'N'; break;
case _IGNORE_BLOCK: _blockType = 'I'; break;
case _CLIENT_BLOCK: _blockType = 'C'; break;
}
if (allocType == _HOOK_FREE) {
if (_size == 0) {
_size = _msize_dbg(userData,blockType);
}
if (userData != NULL) {
typedef struct _CrtMemBlockHeader
{
struct _CrtMemBlockHeader *pBlockHeaderNext;
struct _CrtMemBlockHeader *pBlockHeaderPrev;
char *szFileName;
int nLine;
size_t nDataSize;
int nBlockUse;
long lRequest;
unsigned char gap[4];
} _CrtMemBlockHeader;
_CrtMemBlockHeader *header = (((_CrtMemBlockHeader *)userData)-1);
if (_filename == NULL) {
_filename = header->szFileName;
}
if (_line == 0) {
_line = header->nLine;
}
if (_request == 0) {
_request = header->lRequest;
}
}
}
fprintf(_AllocHookFile,"%10d %10d %c %c %s;%d\n",
_request,_size,_allocType,_blockType,_filename,_line);
return TRUE;
}
The initialize function opens a file where allocations are logged and sets the allocation hook, and the terminate function closes it. The hook function gets called on each heap operation. You can look at the resulting log file to see where things are allocated and deallocated.
Software Zen: delete this;
|
|
|
|
|
I have a nice mfc control and want to use this control under WinCE (PocketPC).
So the problem is that the control uses very often the following functions
CDC::SetTextAlign(...);
CDC::TextOut(...);
and this 2 functions are not supported under WinCE.
I know I can write CDC::ExtTextOut(...); or CDC::DrawText(...); instead of CDC::TextOut(...); , but I have to recalc all the positions where to plot the text, because the CDC::SetTextAlign(...); function is not supported by WinCE.
Is it possible to write this two functions, so that I don't need to recalc all the positions!
Or any other idea?
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
I am using VC++ 7.0, with a simple wizard generated MDI applictaion, and I am reporting the warning LNK4089: 'all references to oledlg.dll will be cancelled by /OPT:REF' (as i have this option enabled). The application itself works fine but the documentation suggests to cut all the references to unnecessary dlls. I have carefully browsed the project settings dialog but couldn't find an option to get this result.
any info/tip will be greatly appreciated
Thanks in advance
|
|
|
|
|
Remove oledlg from the list of libraries under the link options (input). This is a message that can basically be ignored. I wouldn't worry about it.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Why does this piece of code create a totally frozen window?
It paints(once?), but can't be moved, resized or clicked on
It seems to work for the first time after I-don't-know-what(Worked once this morning, never again. Last night didn't work. Haven't restarted)
<br />
#define IB_BACKGROUND BLACK_BRUSH<br />
#define IB_TILESET_ID 5141 // <- Should this be some number that means anything? I am not sure what it is needed for<br />
<br />
<br />
if (!m_wndTileset.Create(AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, 0,<br />
(HBRUSH)::GetStockObject(IB_BACKGROUND), 0), "Tileset", WS_VISIBLE | WS_CAPTION<br />
| WS_SIZEBOX, theApp.m_lastTilesetRect, this, IB_TILESET_ID))<br />
{<br />
TRACE0("Failed to create tileset window\n");<br />
return -1;<br />
}
I am doing this in CMainFrame::OnCreate
m_wndTileset is a CWnd derived class without any real modifications yet.
|
|
|
|
|
do u use loop, i.e. while(), for() somewhere? if yes, check them first.
includeh10
|
|
|
|
|
Nope. I don't do absolutely anything with that window besides creating it and updating the theApp.m_lastTilesetRect on move & size. No loops in that either.
|
|
|
|
|
i wrote a program which borrow some mfc class, when i let my view derive from CWnd, it runs OK, but when i let it derive from CHtmlView, it crashed. anybody knows why, the code is below:
//StdAfx.h
#include <afxwin.h>
#include <afxext.h>
#include <afxcmn.h>
#include <afxhtml.h>
//StdAfx.cpp
#include "StdAfx.h"
//MainFrm.h
#include "SimpleHtmlView.h"
class CMainFrame : public CFrameWnd
{
protected:
DECLARE_DYNCREATE(CMainFrame)
// Constructor & Destructor
public:
CMainFrame();
virtual ~CMainFrame();
// Attributes
protected:
CStatusBar m_wndStatusBar;
CSimpleHtmlView m_wndView;
// Methods
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
DECLARE_MESSAGE_MAP()
};
//MainFrm.cpp
#include "StdAfx.h"
#include "SimpleHtml.h"
#include "MainFrm.h"
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR,
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
CMainFrame::CMainFrame()
{}
CMainFrame::~CMainFrame()
{}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.dwExStyle = 0;
cs.lpszClass = AfxRegisterWndClass(0, 0, 0, ::LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDR_MAINFRAME)));
return TRUE;
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
//Register the windows class for its creation
if ( CFrameWnd::OnCreate(lpCreateStruct) == -1 )
return -1;
if ( !m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators) / sizeof(UINT)) )
{
TRACE0("Failed to create status bar\n");
return -1;
}
if ( !m_wndView.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;
}
return TRUE;
}
//SimpleHtml.h
#include "Resource.h"
class CSimpleHtmlApp : public CWinApp
{
// Constructor & Destructor
public:
CSimpleHtmlApp();
virtual ~CSimpleHtmlApp();
// Methods
virtual BOOL InitInstance();
protected:
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP();
};
//SimpleHtml.cpp
#include "StdAfx.h"
#include "SimpleHtml.h"
#include "MainFrm.h"
BEGIN_MESSAGE_MAP(CSimpleHtmlApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
END_MESSAGE_MAP()
CSimpleHtmlApp theApp;
CSimpleHtmlApp::CSimpleHtmlApp()
{}
CSimpleHtmlApp::~CSimpleHtmlApp()
{}
BOOL CSimpleHtmlApp::InitInstance()
{
CMainFrame* pMainFrame = new CMainFrame();
if( !pMainFrame->LoadFrame(IDR_MAINFRAME) )
return FALSE;
m_pMainWnd = pMainFrame;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
void CSimpleHtmlApp::OnAppAbout()
{
CDialog aboutDlg(IDD_ABOUTBOX);
aboutDlg.DoModal();
}
//SimpleHtmlView.h
class CSimpleHtmlView : public CHtmlView
{
protected:
DECLARE_DYNCREATE(CSimpleHtmlView)
// Construction & Destructor
public:
CSimpleHtmlView();
virtual ~CSimpleHtmlView();
// Methods
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
DECLARE_MESSAGE_MAP()
};
//SimpleHtmlView.cpp
#include "StdAfx.h"
#include "SimpleHtml.h"
#include "SimpleHtmlView.h"
IMPLEMENT_DYNCREATE(CSimpleHtmlView, CHtmlView)
BEGIN_MESSAGE_MAP(CSimpleHtmlView, CHtmlView)
//{{AFX_MSG_MAP(CSimpleHtmlView)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CSimpleHtmlView::CSimpleHtmlView()
{}
CSimpleHtmlView::~CSimpleHtmlView()
{}
BOOL CSimpleHtmlView::PreCreateWindow(CREATESTRUCT& cs)
{
return CHtmlView::PreCreateWindow(cs);
}
thank you very much
|
|
|
|
|
I'm taking a wild guess here but I believe this article might help you out:
http://www.microsoft.com/msj/0100/c++/c++0100.asp
-------------
-= Nasty_p =-
|
|
|
|
|
HideCaret(hwndEdit) function was just what I was looking for...The problem of the text still being selected still remains. Also if I double click on the edit box select some text and then move around the mouse then the whole thing just gets distorted...Am I doing the right thing by using and edit control to display a text file. Is there another more efficient approach to this matter?
|
|
|
|
|
i may offer some advices but what is u really want?
an edit control on dialog box with read-only (not by style), no selection etc?
includeh10
|
|
|
|
|
Yes, that's exactly what I want. I want basically a control on a dialog which looks and behaves like a list box which does not allow selections. So I figure the edit box is the best way to go about this. From the resource editor I chose multiline/vscroll/read-only. Displays the text file just fine except for when it starts up where everthing is highlighted. The only other problem is that if you start dragging the mouse all over the control then the text gets distorted...maybe I should process mouse messages? So basically that's it. The main problem them is the the text being selected. The HideCaret() function was very nice. Thanks for your help.
|
|
|
|
|
basic solution needs 1 second.
if u have more than 2 controls on dialog, extra one may be any except CStatic. goto resource edit, from menu tool(?) then select TAB order, change the edit control not as first. that is all.
but the edit is light-gray. for high level solution, u need to override the edit to handle message.
includeh10
|
|
|
|