|
ClassWizard is a MFC facility. I'm not sure if class-wizard is supported in a static-lib, even if you set-up the lib to use MFC. I only have one static lib that uses MFC and I can't see any options to enable class-wizard for it.
Michael
CP Blog [^]
|
|
|
|
|
Hai all,
I am doing an application VC++ 6.0 MFC.
In my application, I have to add folders in the TreeView Control.
The folders are physically present in a system directory.
If i choose a folder from the Treeview, the contents of the folder
should be displayed in a ListView Control.
how can i place a physical folder in a ListView Control and navigate through it?
please help me.
With thanks and regards
Arun Chakaravarthy.
|
|
|
|
|
I hope this will help you,
The ListView sample demonstrates the extended ListView styles and item indenting.
File: ListView.c
HANDLE g_hInst;
TCHAR szClassName[] = TEXT("ListViewClass");
BOOL g_bCustomDraw;
#define IDC_LISTVIEW 1000
WinMain
int PASCAL WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
INITCOMMONCONTROLSEX iccex;
//required to use the common controls
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
iccex.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx(&iccex);
g_hInst = hInstance;
if(!hPrevInstance)
if(!InitApplication(hInstance))
return FALSE;
/* Perform initializations that apply to a specific instance */
if (!InitInstance(hInstance, nCmdShow))
return FALSE;
/* Acquire and dispatch messages until a WM_QUIT uMessage is received. */
while(GetMessage(&msg, NULL, 0x00, 0x00))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
/******************************************************************************
MainWndProc
******************************************************************************/
LRESULT CALLBACK MainWndProc( HWND hWnd,
UINT uMessage,
WPARAM wParam,
LPARAM lParam)
{
switch (uMessage)
{
case WM_CREATE:
{
HWND hwndListView;
g_bCustomDraw = FALSE;
// create the TreeView control
hwndListView = CreateListView(g_hInst, hWnd);
//initialize the TreeView control
InitListView(hwndListView);
}
break;
case WM_NOTIFY:
return ListViewNotify(hWnd, lParam);
case WM_SIZE:
ResizeListView(GetDlgItem(hWnd, IDC_LISTVIEW), hWnd);
break;
case WM_INITMENUPOPUP:
UpdateMenu(GetDlgItem(hWnd, IDC_LISTVIEW), GetMenu(hWnd));
break;
case WM_CONTEXTMENU:
if(HandleContextMenu(hWnd, wParam, lParam))
return FALSE;
break;
case WM_COMMAND:
return HandleCommand(hWnd, wParam, lParam);
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
break;
}
return DefWindowProc(hWnd, uMessage, wParam, lParam);
}
/******************************************************************************
AboutDlgProc
******************************************************************************/
BOOL CALLBACK AboutDlgProc( HWND hDlg,
UINT uMessage,
WPARAM wParam,
LPARAM lParam)
{
switch (uMessage)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(wParam)
{
case IDOK:
EndDialog(hDlg, IDOK);
break;
case IDCANCEL:
EndDialog(hDlg, IDOK);
break;
}
return TRUE;
}
return FALSE;
}
IF you need further details visit microsoft.com ListViewControl
|
|
|
|
|
Hi everybody,
I need to write a kind of scheduler program in MFC. As far as I know there is a SeTTimer
funtion but it only gives me periodic ON_TIMER message which is not a proper way to alert the program ,for example, at 03.agu.2004 16:30:00.
Please guide me.
Thanks,
Muharrem
|
|
|
|
|
here is you r solution buddy
,just check the current time every time the WM_TIMER message Generate.
like this way
CTime tm=CTime::GetCurentTime();
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Don't you think It is not necessary to check every ,let say, one second if
time has alredy expired or not. I assume there should be some way shorter and smarter
to set a kind of timer for an absolute time. But I don't know how?
Any way thanks for your reply.
Muharrem
|
|
|
|
|
This sounds like a job for the ITaskScheduler interface. See also the ITask and ITaskTrigger interfaces.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I am just starting with C++, and have a problem. I wrote a text game but the thing is some times I want the new question etc to start at the top of a clean black screen (that is erase all previous lines).
I could just put a pile of endl; but a couple of days ago somewhere on the site I saw a clrScrn; statment or something like that and remembered BASIC.
Could someone tell me the the #include and the correct way to use it.
Thanks in advance!
|
|
|
|
|
the DOS-command 'cls' clears the screen.
If you can execute this command...
Good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Here is you solution
If you working in Text mode
see cls() function it is defined in <conio.h>
if you working in Graphis mode
see function cleardevice() ,it is defiend in graphics.h
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
>>erase all previous lines).
For dos baserd compiler... the function is: clrscr();
The header file for it is #include<conio.h>
conio=Console I/O
I hope that makes you happy.
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
im assuming you have Visual C++, unfortunatly VC++ doesnt come with the old functions like gotoxy() or clrscrn() that Dev-C++ offers
here is a ClearScreen() function i wrote along time ago (with SetXY() function)
void SetXY(int X, int Y){
COORD dwCoord;
dwCoord.X = X;
dwCoord.Y = Y;
SetConsoleCursorPosition(STDHANDLE,dwCoord);
}
void ClearScreen(){
COORD dwCoord;
DWORD nLength;
DWORD lpResult;
CONSOLE_SCREEN_BUFFER_INFO Info;
GetConsoleScreenBufferInfo(STDHANDLE, &Info);
dwCoord.X = 0;
dwCoord.Y = 0;
nLength = Info.dwSize.X * Info.dwSize.Y;
FillConsoleOutputCharacter(STDHANDLE, ' ', nLength, dwCoord, &lpResult);
SetXY(0,0);
}
ohh i almost forgot
#define STDHANDLE GetStdHandle(STD_OUTPUT_HANDLE)
|
|
|
|
|
I want to log data into MS-ACCESS from my application.
But if a machine does not have MS-ACCESS, will the application hang?
i also found that there is a microsoft access driver which is really needed instead of MS-ACESS.
Now in my application, i want to first search for the driver(instead of assuming that it is present) and then start logging. Can any1 please give me some knowledge in this matter?
|
|
|
|
|
A lot depends on the method you are using to communicate with Access?
With ADO, you should just need to redistribute MDAC.
This[^] article tells you the files need for redistributing a DAO app.
Michael
CP Blog [^]
|
|
|
|
|
i seem to be having a problem using GetFileSize in MFC
when i get the file size of anything other than an .exe it returns 0
code sample
hFile = ::CreateFile( m_FileToSplit, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if( hFile != INVALID_HANDLE_VALUE )
{
dwFileSize = ::GetFileSize( hFile, NULL );
//doesnt seem to work
//m_FileSize.Format( "File Size: %d KB", dwFileSize );
/**/
if( dwFileSize >= 0x100000 )
{
m_FileSize.Format( "%d%s", (dwFileSize/0x100000), " MB" );
}
else if( dwFileSize >= 0x40000000 )
{
m_FileSize.Format( "%d%s", (dwFileSize/0x40000000), " GB" );
}
else
{
m_FileSize.Format( "%d%s", (dwFileSize/0x100000), " KB" );
}
/**/
CloseHandle( hFile );
}
as you may have noticed my other problem
m_FileSize.Format( "File Size: %d KB", (dwFileSize /0x100000) );
doesnt work while
m_FileSize.Format( "%d%s", (dwFileSize/0x100000), " KB" );
does anyone know why?
extra prob: m_OutputDir.Format( "%s\\%s\\Output", FileDrive, FilePath );
puts double slashes in the edit box, when i do
m_OutputDir.Format( "%s\%s\Output", FileDrive, FilePath );
it only puts single slashes, and i get a warning that \% and \O are not valid escape sequences
|
|
|
|
|
»Archer282« wrote:
//doesnt seem to work
Which means what? Is an error produced? Does the compiler complain? Does GetFileSize() return the wrong size? Does Format() not format the number correctly? Is an assertion fired, or an exception thrown?
How about:
HANDLE hFile = ::CreateFile(m_FileToSplit, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
DWORD dwFileSize = ::GetFileSize(hFile, NULL);
if (dwFileSize != INVALID_FILE_SIZE)
{
CString m_FileSize;
if (dwFileSize < 0x100000)
m_FileSize.Format("%f KB", (dwFileSize / 1024.0));
else if (dwFileSize < 0x40000000)
m_FileSize.Format("%f MB", (dwFileSize / 1048576.0));
else
m_FileSize.Format("%f GB", (dwFileSize / 1073741824.0));
}
CloseHandle(hFile);
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
char temp[] = "1.15";
double dbl = atof(temp);
If I run this code in Visual Studio 6 dbl = 1.15
If I run this code in Visual Studio 2003 dbl = 1.1499999999999999
Can anyone explain this for me please
|
|
|
|
|
i dont know what that would happen.
but you could alwase round it up (i think there is a round function that would suit if not you could always make your own)
|
|
|
|
|
Exactly what is telling you those values ?
I am willing to bet that if you look at the 8-byte binary value they will be identical. It is the output display that is the only thing that differs. If you use a format specifier of "%.2f" with one of the printf family of functions (print, sprintf, or fprintf) I expect that you will see 1.15.
It is important to note that it is virtually impossible to acquire exactly accurate floating point values. There are nearly always rounding errors involved that you must just deal with.
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
Thanks for your reply
I was getting the values from the quick-watch window displayed by the debugger. The 8-byte binary value displayed in the memory window IS the same.
I have found that the real cause of my bug is the use of the pow() function from math.h.
I had code like
long rounding = 4;
double result = pow(10, -rounding);
which in vs6 returns result = 0.0001
and in vs2003 returns result = 0.0
these values ARE different in memory
Looking at math.h I think the code above was calling
long pow(long, long) resulting in 0 and auto casting the result to a double.
I changed it to
double result = pow(10.0, -rounding);
and now it works. Why its different in vs6 and vs2003 I dont know
|
|
|
|
|
As previously mentioned you should not expect an exact comparision when working with floating point numbers. To check equality you need to compare the differnce to epsilon. If the difference is < or = epsilon then the numbers are equal. Otherwise they are not.
This is done as follows: take the absolute value of the difference of the absolute values of the two floating point numbers and compare the result to epsilon. If the difference is less than or equal epsilon then the numbers are equal.
if( FLT_EPSILON =< fabsf( fabsf(f1) - fabsf(f2) ) )
printf( "numbers are equal\n" );
else
printf( "numbers are not equal\n" );
NOTE: there are double precision variants of epsilon and fabsf.
Sam
Sam
|
|
|
|
|
Hi,
My VC++ solution has 10 projects with 40 .rc files. I want to assign unique ID's to the ID's in resource.h files as there are many duplicates. So got a ResOrg.Net tool. I ran this tool which generated unique numbers for the IDs. But my application is not launching, something went wrong. I don't know what??
Can anybody help.
Also I want to allot some range ID's for all the projects.
eg. Proj 1 -> 1 - 1000
Proj 2 -> 1001 - 2000
etc....
Will there be a problem if I try alloting the ID's in this manner?
Thanks,
Prashant
|
|
|
|
|
When I have a lot of projects, I start redifining range of IDS at the bottom of the H file. All goes OK.
Jaime
|
|
|
|
|
Jaime,
The problem arises when the numerical value used by the IDS/any control is the same as some other control in another project.
At run time, the wrong string/control would be used. So for this we have to have unique ID's across all projects correct? So I am doing the cleanup, please help me out on some tools/documents available on net if any..
Thanks,
Prashant
|
|
|
|
|
I told you that I start redifining all range ID's. That way, all ID's become unique for all projects so I never have problems with that.
Since I know about that problem, I modify the ranges when I create the projects. Sorry, but I don't know any tool that does it automatically when the projects are already created.
If the application didn't launch after your modification, you only have to debug it. That's the solution to find what ID was the problem.
Jaime
|
|
|
|