|
:: is the Scope Resolution Operator[^].
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Well, I know that this is scope resolution operator but I am not able to understand what it does.
Anyways, Thanks
Preeti9
|
|
|
|
|
Preeti9 wrote:
I know that this is scope resolution operator but I am not able to understand what it does
It resolves the scope of objects . For example std::string tells the compiler to use the string class that is a member of the std namespace.
In your example ShowList::ShowList( void ) you are declaring the default c'tor of the class ShowList ( a c'tor is a function that has the same name as the class). In the same file you could have a function called MyShowList::ShowList( void ) which would be the ShowList function of the MyShowList class. Without the scope resolution operator the compiler would not be able to tell the two apart.
Read some of the links I gave you earlier, and experiment with some code. The concept is not all that difficult.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks, I got it now. It is not difficult.
Thanks once again
Preeti9
|
|
|
|
|
I have Printpreview difficult.
I want from doc/view facilities, to preview all I need to print.
According to all theories I read, i must create my View class derived from CPreviewView, but in my Visual C++ Standard Edition 6.0, i don't have it. how to do now ?
Would you like to send me this library ? (lib file).
Urgent
I learn my self
|
|
|
|
|
CPreviewView is declared in AfxPriv.h and it's implementation is in ViewPrev.cpp. You should have both those files.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Where to find those files, I need them.
And to use it to create my View class from them.
Or send me only the lib of this class
I learn my self
|
|
|
|
|
Please Sir, T say that I am using Visual c++ 6.0 standard edition. I thing that's my problem, if perhaps i had professionnal edtion, I would resolve my problem, so i ask if it is possible to send me this class like a librairy to incorporate it to my project.
Thanks
I learn my self
|
|
|
|
|
The files are included in the edition you have. AfxPriv.h is in the VC98/MFC/Include/ folder and ViewPrev.cpp is in the VC98/MFC/SRC folder.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
A create a new project. And I create a new view derived from CPreviewView.I insert Afxpriv.h and Viewprev.cpp files in my project.
Now I have this error message :
c:\Program Files\Microsoft Visual Studio\Vc98\Mfc\Src\Viewprev.cpp(169) : error C2491: 'CPreviewView::messageMap' : definition of dllimport static data member not allowed.
What to do ?
I learn my self
|
|
|
|
|
Do not add viewprev.cpp to your project. The file has already been compiled into the MFC42.dll file that contains all the MFC binaries. The file is include with VC so that you can step through it when debugging and/or so that you can read the source to see how MFC is implemented. That goes for all files in the VC98/MFC/SRC/ folder.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks,
I have now derived my view class from CPreviewView. And I add a command handler UI OnFilePreview()like this :
if (!DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, this,
RUNTIME_CLASS(CPreviewView), pState))
{
// In derived classes, reverse special window handling
// here for Preview failure case
TRACE0("Error: DoPrintPreview failed");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
delete pState; // preview failed to initialize,
// delete State now
}
But it not works well. Not Toolbar menu and it hang also
I learn my self
|
|
|
|
|
I have seen again that DoPrintPreview() is not CPreviewView function.
What to do now to make a printpreview ?
I learn my self
|
|
|
|
|
Hi
I have a RS232 problem. I can initiate the COM1 handle. But when I try to read or write, it just hangs there - look like deadlock. How can I solve this problem?
Thank you very much,
|
|
|
|
|
Could it be a handshaking problem? This is very common so make sure flow control is turned off since it has to be working at both ends.
The tigress is here
|
|
|
|
|
Thank you very much for your reply. I double check the flow control setting.
I am using "PJ Naughter" Serial class. like:
CSerialPort::GetDefaultConfig(1, config);
CSerialPort port;
port.Open(1, 9600, CSerialPort::NoParity, 8, CSerialPort::OneStopBit, CSerialPort::NoFlowControl);
HANDLE hPort = port.Detach();
port.Attach(hPort);
DWORD dwModemStatus;
port.GetModemStatus(dwModemStatus);
DCB dcb;
port.GetState(dcb);
dcb.BaudRate = 9600;
port.SetState(dcb);
DWORD dwErrors;
port.ClearError(dwErrors);
port.SetBreak();
port.ClearBreak();
COMSTAT stat;
port.GetStatus(stat);
COMMTIMEOUTS timeouts;
port.GetTimeouts(timeouts);
port.Setup(10000, 10000);
port.GetConfig(config);
config.dcb.BaudRate = 9600;
port.SetConfig(config);
port.Set0WriteTimeout();
port.Set0ReadTimeout();
char sBuf[] = "This should appear on the serial port";
port.Write(sBuf, strlen(sBuf)); -------------------------> Stop here
What kind of reason cause this problem?
Thank you very much!
|
|
|
|
|
I assuem you have tried iusing Hyperterminal, To make sure the comms link is working oK? e.g. that he cable is OK etc.
"An education isn't how much you have committed to memory, or even how much you know. It's being able to differentiate between what you do know and what you don't." - Anatole France
|
|
|
|
|
I have a sample application that is registering for the notification of the file-create . I am using SHChangeNotifyRegister API to get the notifcation . Since my appln is to be supported in 98/me i haved used this . But when i copy around 50 files .. .. I am getting notification of only 20 files .. .I have attached the code for your reference
Header file
#define WM_USER_MEDIACHANGED WM_USER+88
// For the Shell notifier, to indicate the type of events for which to receive
// notifications.
#define SHCNF_ACCEPT_INTERRUPTS 0x0001
#define SHCNF_ACCEPT_NON_INTERRUPTS 0x0002
#define SHCNRF_RecursiveInterrupt 0x1000
typedef struct {
DWORD dwItem1; // dwItem1 contains previous PIDL or name of the folder.
DWORD dwItem2; // dwItem2 contains the new PIDL or name of the folder.
} SHNOTIFYSTRUCT;
// Memeber Functions.
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
.cpp file
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MSG Msg;
HWND hWnd;
WNDCLASSEX WndClsEx;
ULONG l_ulSHChangeNotifyRegister;
const char *ClsName = "BasicApp";
const char *WndName = "A Simple Window";
// Create the application window
WndClsEx.cbSize = sizeof(WNDCLASSEX);
WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
WndClsEx.lpfnWndProc = WndProcedure;
WndClsEx.cbClsExtra = 0;
WndClsEx.cbWndExtra = 0;
WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClsEx.lpszMenuName = NULL;
WndClsEx.lpszClassName = ClsName;
WndClsEx.hInstance = hInstance;
WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
//BY_HANDLE_FILE_INFORMATION handle;
// Register the application
RegisterClassEx(&WndClsEx);
hWnd = CreateWindow(ClsName,
WndName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if( !hWnd ) // If the window was not created,
return 0; // stop the application
// Display the window in hidden mode.
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
// Get the folder locations of the folders to be monitored using the CSIDL_XXXX values and
// store it in the identifiers list.
LPITEMIDLIST ppidl = NULL;
if(SHGetSpecialFolderLocation(hWnd, CSIDL_DRIVES , &ppidl) == S_OK)
{
SHChangeNotifyEntry shCNE;
shCNE.pidl = ppidl;
shCNE.fRecursive = TRUE;
// Returns a positive integer registration identifier (ID).
// Returns zero if out of memory or in response to invalid parameters.
l_ulSHChangeNotifyRegister = SHChangeNotifyRegister(hWnd,// Hwnd to receive notification
SHCNF_ACCEPT_INTERRUPTS | SHCNF_ACCEPT_NON_INTERRUPTS|SHCNRF_RecursiveInterrupt ,
// Events of interest - use
SHCNE_CREATE,
// Notification message to be sent when the event has occured
WM_USER_MEDIACHANGED,
// Number of entries in the pfsne array should always be 1
1,
// Array of SHChangeNotifyEntry structures that
// contain the notifications.
&shCNE);
}
else
{
// Log error in retrieving folder info of system.
}
while( GetMessage(&Msg, NULL, 0, 0) )
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
// Window call back function
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_DESTROY:
arr.Format("%d",nCount);
MessageBox(NULL,arr,"Message",MB_OK);
PostQuitMessage(WM_QUIT);
break;
case WM_USER_MEDIACHANGED:
switch(lParam)
{ case SHCNE_CREATE: //File create
if (TRUE == SHGetPathFromIDList((struct _ITEMIDLIST *)shNotifyStr->dwItem1, sourcePath))
{
nCount++; }
break;
default:
break;
}
default:
// Process the left-over messages
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
|
|
|
|
|
For performance reasons, multiple notifications may be combined into a single notification.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
thanks . You mean to say for performance reason Windows OS itself is giving only few notifications ? . Is there anyway to overcome this problem .
|
|
|
|
|
ragavan wrote:
You mean to say for performance reason Windows OS itself is giving only few notifications ?
That's exactly what I'm saying.
ragavan wrote:
Is there anyway to overcome this problem .
What problem?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I had asked yesterday if there was a way to look at all the files in a directory and I was directed to CFileFind, but for some reason, as I use .FindNextFile() and .GetFileName(), it's skipping like 4 files every time! Any help?
Danny
|
|
|
|
|
|
Actually, I have to retract that question. It does seem to search all the files, just in a different order than I would have expected. It does seem, though, that when I try to open the file just after I found it that the file doesn't open.
Here's the code I'm working with...
CFileFind finder;
BOOL bWorking = finder.FindFile(searchPath);
while (bWorking)
{
bWorking = finder.FindNextFile();
fileList[counter] = (LPCTSTR) finder.GetFileName();
path = (LPCTSTR) finder.GetFilePath();
examine.open(path, ios::in | ios::nocreate | ios::noreplace);
.
.
.
}
(fileList is an array of CStrings, path is a CString, and examine is an fstream.)
Is the finder possibly interfering with opening the file?
Danny
|
|
|
|
|
bugDanny wrote:
fileList[counter] = (LPCTSTR) finder.GetFileName();
path = (LPCTSTR) finder.GetFilePath();
While not related to the actual problem, the two casts are unnecessary.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|