|
A static method can't access non-static member variables. You'll need to pass a pointer to either this or just the CProgressCtrl to the callback function.
--Mike--
"So where does that leave us? Well, it leaves us right back where we started, only more confused than before." -- Matt Gullett
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
In the head file----------------
//{{AFX_DATA(CFormatNT)
enum { IDD = IDD_DIALOG_FORMAT };
CProgressCtrl m_progress;
//}}AFX_DATA
.....
-------------------------------------
static BOOL CALLBACK FormatDiskCallback( ...,CProgressCtrl progressBar);
static void PrintOut(...PFMIFSCALLBACK FormatExCallback,CProgressCtrl m_progress);
.......
In the implementation file-----------------------------------------
typedef BOOL (CALLBACK *PFMIFSCALLBACK)( ...,CProgressCtrl progressBar );
-------------------------
BOOL CALLBACK CFormatNT::FormatDiskCallback(...,CProgressCtrl progressBar)
{
......
m_progress.SetPos(10);
......
}
void CFormatNT::PrintOut(..., PFMIFSCALLBACK FormatExCallback,CProgressCtrl m_progress)
{
....
FormatExCallback(...,m_progress);
}
...
PrintOut(...,m_progress);
...
Compile it, and the result is:
error C2664: 'PrintOut' : cannot convert parameter 3 from 'class CProgressCtrl' to 'class CProgressCtrl'
What is the problem? And how to solve it?
|
|
|
|
|
Now I have completed the function by using another new thread.
Not handling the CProgressCtl varible in the static function.
|
|
|
|
|
how to play *.ani file in MFC?
I dont want to use the function "LoadCursorFromFile"
I want to use it as a resource.
How do i do!
|
|
|
|
|
Robert,
I am very interested in your code to change the static text and background colors. I have entered in the code to do that from your code, but the colors do not change. Could I send you the code and have you take a look and see what is wrong?
Thanks very much,
George
|
|
|
|
|
hi..
I create a subclassed MFC ActiveX control .. Subclassed from the Listbox control .. a have a method that should add an item :
the code causes an assertion .. can anyone help ?
void CSubCtrl::AddItem(BSTR FAR* strItem) <br />
{<br />
<br />
CString st(*strItem);<br />
CListBox lb;<br />
lb.Attach(COleControl::m_hWnd);<br />
lb.AddString(st);<br />
lb.Detach();<br />
<br />
}
|
|
|
|
|
When talking about assertion, it's needed to know what is its condition from the file it exists in.
However, I guess that the possible assertion that could occur in your code is the IsWindow() assertion (ASSERT(::IsWindow(hWnd)) which indicate the the HWND passed to the Attach() function is invalid.
When you get an assertion in debug mode, click retry to see the assertion condition.
|
|
|
|
|
Hi..
the asseion occures in Attach method .. when i step in the code i find that ASSERT(FromHandlePermanent(hWndNew) == NULL); causes an assetion..
any suggestion please ?
|
|
|
|
|
Hello!
I am an electronics hobyist, I am interested in writing programs for interfacing with my homebrew electronics projects. Is there a generic serial port driver for Win32 environment using open source for download?
|
|
|
|
|
|
Hello,
I am looking for a directive like #error, but one that doesn't stop the compiler. So something like #message...
Does such a directive exist?
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Try #pragma message("My Message")
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Ah, thanks
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
You're welcome
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I want to design an MFC program that processes part numbers, I'm not sure which is the best way to go. Could someone please give me some advice on creating this type of program. I've had two people recommend a database, but I'd like to hear a few more opinions.
Thanks much
|
|
|
|
|
You can download mySQL at http://www.mysql.com
It's free for private use.
|
|
|
|
|
Hello. I am doing a about cd-rom test program. I want to read CD-ROM data test. But I don't know read CD-ROM data. Can you help me? Thanks.
welcome to meet you!
|
|
|
|
|
|
You can open the CD as a volume. This way you reads the volume in raw mode (sector by sector).
The trick is to open the volume like this (assuming your CD-Rom i drive G:, (char) m_CurDrive == 'G')
#include "winioctl.h"
...
char NtDriveName[10];
sprintf(NtDriveName, "\\\\.\\%c:", m_CurDrive);
hDrive = CreateFile(
NtDriveName,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL
);
Then you lock the drive and read geometry for it (in order to get the sector size):
DWORD ReturnedByteCount;
DeviceIoControl(hDrive, FSCTL_LOCK_VOLUME,
NULL, 0, NULL, 0, &ReturnedByteCount,
NULL);
// Get the geometry:
DISK_GEOMETRY Geometry;
DeviceIoControl(hDrive, IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL, 0, &Geometry, sizeof(Geometry),
&ReturnedByteCount, NULL);
// Now you got the sector size (in Geometry.BytesPerSector).
// At this point, you can unlock the volume if you wish. It's the IOCTL_DISK_GET_DRIVE_GEOMETRY call who needs the drive to be locked.
IoBuffer = malloc (Geometry.BytesPerSector);
....
// Read sector by sector, starts with sector 0
// Positionera
if(SetFilePointer(hDrive, (long)
(Geometry.BytesPerSector * (int) "your wanted start-sector"),
NULL, FILE_BEGIN) == 0xFFFFFFFF) {
// Couldn't seek to it.
return FALSE;
}
// Read
b = ReadFile(hDrive,IoBuffer, Geometry.BytesPerSector, &BytesRead, NULL);
if (b && BytesRead){
// OK, read
.....
}
.....
// unlock the volume
DeviceIoControl(hDisk, FSCTL_UNLOCK_VOLUME,
NULL, 0, NULL, 0, &ReturnedByteCount,
NULL);
// close the volume
CloseHandle(hDrive);
free IoBuffer;
Note, this code isn't compiled! But it's assembled from working code (a routine that reads UNIX tar-media (diskettes and CD) in NT 4).
Good luck.
Kakan.
|
|
|
|
|
I would like to create an active X control using VC++ 6.0 in which, apart from my application specific properties and methods , I also want to have a MsComm Control (for serial port communications) as a member variable in the user activeX property page class which gets generated by the apllication wizard. The following are the steps I had taken to do so.
1. Used MFC ActiveX control Wizard to create a ActiveX application.
2. Added the MsComm active X control in the resource tool box. (The phone icon was visible in the toolbox)
3. Added the MsComm Control in the Property page dialog box (which was created automatically by the wizard).
4. Assigned a member variable, say, m_Comm to the control.
5. Added a method to the control class (automatically generated by the wizard) called OpenPort, in which I called the m_Comm.SetSettings("9600,N,8,1") function.
6. Compiled and created a ActiveX control.
So far so good ..... No Hassles.
7. Created a Dialog based MFC application in which I used this ActiveX control. Provided a button in the dialog to trigger the OpenPort Function of the active X.
Now the hassles start......
8. The program crashes.
9. I debugged the code of the activeX project and found that the address m_Comm variable was NULL instead of a meaningfull value.
Where did I go Wrong?
|
|
|
|
|
I do this for an array of COM ports (element 0 shown):
Comport[0] = &m_comm0;
// Set up the COM ports
Comport[0]->SetCommPort( (short)i + 2); // start at COM2
Comport[0]->SetInBufferSize(2040); // both buffers to just under 2K
Comport[0]->SetOutBufferSize(2040);
Comport[0]->SetRThreshold(1); // call OnComm event after 1 char reced.
Comport[0]->SetSettings(cstr1);
if (! Comport[0]->GetPortOpen()) // if the port is closed, open it
Comport[i]->SetPortOpen(TRUE);
Also, the ON_COMM event handler is set up to be called by 1 character recieved. Note that var is declared as a VARIANT and that the condition of checking for a non zero length is because once in several million events this is called with no received character. There may be more than one character received in the string.
if(Comport[Port]->GetCommEvent() == 2)
{
VARIANT var;
// character(s) received ?
var.vt = VT_BSTR; // yes, we get a BSTR back
var = Comport[Port]->GetInput();
cstr1 = var.bstrVal; // convert to a CString for convenience
if(cstr1.GetLength() > 0) // if anything to add
{
// do it here
}
}
Elaine
The tigress is here
|
|
|
|
|
when I use SHGetFolderLocation in my program, system tells me :
error C2065: 'SHGetFolderLocation' : undeclared identifier
Error executing cl.exe.
My IDE is VC6+win2000
who can help me?TIA
|
|
|
|
|
have you included shlobj.h?
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Exactly, I've done that, but error is still there,later on , I try this:
#pragma comment(lib, "shell32")
It does not work yet! I dont know why!
|
|
|
|
|
I don't know then. This is what I got from MSDN on the error:
Compiler Error C2065
'identifier' : undeclared identifier
The specified identifier was not declared.
A variable’s type must be specified in a declaration before it can be used. The parameters that a function uses must be specified in a declaration, or prototype, before the function can be used.
Tips
Make sure any include file containing the required declaration is not omitted.
Make sure you are including any necessary header files if you have defined VC_EXTRALEAN, WIN32_LEAN_AND_MEAN, or WIN32_EXTRA_LEAN. Defining these symbols excludes some functionality (certain header files are excluded) from windows.h and afxv_w32.h (for MFC applications) to speed compiles. Search windows.h and afxv_w32.h for these symbols for the most up-to-date description of what is excluded.
Make sure the identifier name is spelled correctly.
Make sure the identifier is using the correct upper- and lowercase letters.
Make sure all string constants have closing quotes.
This error can be caused by having a newline character in a string constant without a continuation character. For example:
#include <stdio.h>
main() {
printf("\n %s
%s // error: 's' : undeclared identifier
%s",
"this", "is", "it");
}
Special considerations must be taken when splitting a constant string over several lines. The most common method is to change the format string. Strings separated only by whitespace (spaces, tabs, newlines) are concatenated. For example:
#include <stdio.h>
main() {
printf("\n %s"
" %s"
" %s",
"this", "is", "it");
}
An older, less-preferred method is to use line continuation by typing a backslash at the end of a line. For example:
printf("\n %s\
%s\
%s",
"this", "is", "it");
This method is not often used because the spaces at the beginning of each continued line become part of the string.
Make sure you're using proper namespace scope. For example, in order to properly resolve ANSI C++ Standard Library functions and operators, you must state that you're using the std namespace with the using directive.
For example, unless the using directive is uncommented, the following sample will fail to compile because the cout stream is defined in the std namespace:
#include <iostream>
// using namespace std;
void main()
{
cout << "Hello" << endl;
}
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|