|
I think your comments are a tad harsh, particularly your choice of language.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
int begin = sName.FindOneOf("0123456789");
if (begin == -1)
{
}
iPanNo = atoi((LPCSTR)s + begin);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Read from right - to - left.
Check if digit and set position for the left most digit.
Deduct position from length and then you can get the length of your string.
|
|
|
|
|
If you're reading from right to left, you could as well perform the conversion yourself as you pass over each digit.
|
|
|
|
|
Hi All,
I am having a tabbed dialog and all the pages contains several controls. After clicking to any control (say a radio button) if I press escape button on my keyboard the entire page became blank.
Please any one put some light on this. Thanks in advance.
Regrads,
Sandip
|
|
|
|
|
Override CDialog::OnCancel() for your all child dialogs, and do nothing there.
|
|
|
|
|
To read asynchronously there is an way-> overlapped I/O.
Open file with FILE_FLAG_OVERLAPPED flag, pass OVERLAPPED structure to ReadFile, and wait for overlapped event for some limited time.
I did not find any sample for this. There are many samples to read from COM device.
But i need a sample to read data from disk/drive/file
|
|
|
|
|
|
Thanks for your reply. It's good article and helped me. To define time i need to create an event and calcel read operation there if it takes long time. But the problem is i am calling ReadFile in a thread (GUI thread). Will it be good to create an event in thread and call another thread from this thread. Please suggest.
|
|
|
|
|
Usually (slow) I/O operation are done on a separate thread (to make the GUI responsive). Why do you need an event when you have timeouts on ReadFile (maybe I didn't got you)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Without using overlapped, Sometime ReadFile takes very long time(say 5 minutes) to read some data. And this create a big issue for me because after that ReadFile does not read any data from any offset. So i decided to use IO overlapped. Passed FILE_FLAG_OVERLAPPED in CreateFile and OVERLAPPED structure in ReadFile.
But here also when i call GetOverlappedResult after ReadFile program hangs because GetOverlappedResult takes 5 minutes. So i decided to create event for OVERLAPPED STRUCTURE. After creating event i call a thread where i check the elapse time. And if time pass more than 1 minutes then i call CancelIO operation to cancel the GetOverlappedResult but still it did not help me. Please check my below code and suggest
in header file, define 2 variables
OVERLAPPED osReadOperation;
HANDLE hFile;
in cpp file
void myfunc()
{
TCHAR szFileName[255];
memset(szFileName,0,sizeof(szFileName));
sprintf(szFileName,"\\\\.\\PHYSICALDRIVE0");
hFile = CreateFile(szFileName,
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
return;
BOOL fOverlapped = FALSE;
char* pDataBuf = new char[83886081];
memset(pDataBuf,0,sizeof(pDataBuf));
DWORD NumberOfBytesRead = 0;
DWORD NumberOfBytesTransferred = 0;
memset(&osReadOperation,0,sizeof(osReadOperation));
osReadOperation.hEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
SetEvent(osReadOperation.hEvent);
AfxBeginThread(myThread, this);
int result = 0;
if (!ReadFile(hFile,pDataBuf,83886080,&NumberOfBytesRead,&osReadOperation ))
{
if (GetLastError() != ERROR_IO_PENDING)
return;
else
fOverlapped = TRUE;
}
else
fOverlapped = FALSE;
if (fOverlapped)
{
if (GetOverlappedResult( hFile,&osReadOperation,&NumberOfBytesTransferred,TRUE))
result = 1;
else
return;
}
else
result = 1;
CloseHandle(osReadOperation.hEvent);
osReadOperation.hEvent = NULL;
}
void CAlldrivesDlg::canceltheoperation()
{
CancelIo(hFile);
}
UINT myThread(LPVOID me)
{
CAlldrivesDlg *th = (CAlldrivesDlg*)me;
OVERLAPPED * self = &th->osReadOperation;
DWORD ww = WaitForSingleObject(self->hEvent, 1000);
int bm=2;
switch(ww)
{ /* waitfor */
case 0:
th->canceltheoperation();
break;
default:
break;
} /* waitfor */
ResetEvent(self->hEvent);
return 0;
}
|
|
|
|
|
Probably, in your case, setting TRUE the bWait parameter of the GetOverlappedResult function is not a good idea, see the "Testing for the End of a File" MSDN sample.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for the link. I noticed that it does not use time. So with this code am i able to handle the case when diskio takes long time to read any data (say 4-5 minutes).
For my case my program reads any data in few seconds but at one offset it takes some minutes to read some data (sometimes hour). Will this code solve that problem? If not then what is the solution? Should i attach the sample source code here which use overllaped io.
|
|
|
|
|
Hi,
I need to customize a CMFCPropertyGrid such that be able to display a simple button inside.
when user selects given grid, user can press button inside and then a dialog box will be displayed!
exactly like Folder dialog box.
how can i do this?
best regards
|
|
|
|
|
Hello Friends
I am using libtiff library and m writing a simple tiff file.I setted the basic tags like imagewidth,height,compression,bitsperpixel,tiff tag orientation and finally image data by using tiffWritescanline. And image is saving as tiff too but now i want to save another layer data in same tiff so for that Do I need to save only image dat or do I need to set basic tag again for that layer too?
Any Help will be appreciated.
Thanks & Regards
Yogesh
|
|
|
|
|
Hello Guys
I found one tag TIFFWriteDirectory in Libtiff but it is creating multiple pages and I want layers in tiff that can I open photoshop and edit it.
Any Other Tag which can make images as Layers?
Thanks & Regards
Yogesh
|
|
|
|
|
TIFF files can contain multiple images (also called "pages"), which are stored in "directories". but again, there is no explicit support in the TIFF format for "layers".
to write N images to a TIFF file, you:
0. open the TIFF file
1. set all the image tags for image X
2. write the image data for image X
3. call TIFFWriteDirectory
4. X++
5. while X < N, goto 1
TIFFWriteDirectory creates and initializes a new tag directory in the TIFF file.
you can also add new pages to an existing TIFF file by opening the file in append mode.
|
|
|
|
|
Chris Losinger wrote: there is no explicit support in the TIFF format for "layers".
According to this[^] (and other sources), there is.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
not really a lot of detail there.
a file search of the latest LibTiffs (3.9.4 and 4.0.0 b6) turns up three instances of the word "layer", none of which refer to Photoshop-style image layers - they refer to API layers, etc..
if there is layer support in TIFF, it must be very new, and so is unlikely to be what Photoshop has been using for years.
|
|
|
|
|
Hi all,
i was looking for a way to change the tooltip of the toolbar's buttons !! i tried to look for it on google but there is nothing versatile.
I'm using Visual Studio 2005 and an MFC project !!
Thank you
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
I believe you would want to send TTM_DELTOOL message to your existing tooltip control to delete the current text, followed by a TTM_ADDTOOL message with the new text. Alternatively, I think you can use TTM_SETTOOLINFO to modify the text of an existing tooltip - that may be simpler.
The following snippet shows the syntax for TTM_ADDTOOL and may point you in the right direction, although the code is WTL instead of MFC:
TOOLINFO info;
ZeroMemory(&info, sizeof(TOOLINFO));
info.cbSize = sizeof(TOOLINFO);
info.hinst = _Module.get_m_hInst();
info.uFlags = ( TTF_CENTERTIP | TTF_ABSOLUTE);
info.lpszText = _T("Your new text here.");
m_Toolbar.GetItemRect(m_Toolbar.CommandToIndex(ID_TOOLBAR_BUTTON_TO_CHANGE ), &info.rect);
info.hwnd = m_Toolbar.m_hWnd;
info.uId = ID_TOOLBAR_BUTTON_TO_CHANGE;
::SendMessage(tt, TTM_ADDTOOL, 0, (LPARAM)&info);
L u n a t i c F r i n g e
|
|
|
|
|
I drived a class from CFormView. But If I override OnInitUpdate it is not executed in my drived class.
Could you help me why this is happening?
|
|
|
|
|
Can you give us a sample of the OnInitUpdate function? We can't really make any educated guesses without any clues.
|
|
|
|
|
john5632 wrote: But If I override OnInitUpdate it is not executed in my drived class.
How are you verifying this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
may be u forgot to attach the ID of the form in the .H classe file !!
is the form loaded or no ? and what kinf of errors do u ve got ?
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|