|
Hi!!!
How it is possible that the following application had 1 thread when is running on Win NT and 2 when is running on Win2000!?
// TestWin2000.cpp : Defines the entry point for the console application.
//
#include <winsock2.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
WSAData wsData;
::WSAStartup(0x0202,&wsData);
char name[64];
gethostbyname((char*)name);
WSACleanup();
printf("\n");
return 0;
}
TIA,
Carlos Marcão
|
|
|
|
|
HELP! I'm launching a thread (code snippet below) that is supposed to monitor the directory c:\MyFolder for any file creations/deletions using ::FindNextChangeNotification. I'm getting a valid handle from the ::FindFirstChangeNotification but I am _not_ getting a change notification when I move a file into the directory or delete a file form the directory. I thought that the system records the change and the WaitForSingleObject call after the ::FindNextChangeNotification call would detect the change but nothing is happening. Any ideas? THanks.
unsigned __stdcall CEventChange::WatchThread(LPVOID pThis)
{
HANDLE hChange = ::FindFirstChangeNotification("c:\\MyFolder", TRUE, FILE_NOTIFY_CHANGE_FILE_NAME);
if(hChange == INVALID_HANDLE_VALUE)
{
// do error processing
return 1;
}
BOOL bReturn;
while(true)
{
bReturn = ::FindNextChangeNotification(hChange);
// check function status
if(bReturn != 0)
{
dwMessageId = WaitForSingleObject(hChange, 0);
if(dwMessageId == WAIT_OBJECT_0)
{
// process event change;
}
else if(dwMessageId == WAIT_FAILED)
{
// do error processing
}
}
else
{
// do error processing
}
Sleep(pThisObject->m_dwInterval);
}
::FindCloseChangeNotification(hChange);
return 0;
}
|
|
|
|
|
Try calling WaitForSingleObject immediately after FindFirstChangeNotification( ). After you have processed each change notification you should call FindNextChangeNotification( ).
|
|
|
|
|
Thanks for the reply. By making code change below, I was able to get the Change notification
// create a change notification handle with initial change notification filter
HANDLE hChange = ::FindFirstChangeNotification("c:\\Harris\\APServices", TRUE, FILE_NOTIFY_CHANGE_FILE_NAME);
if(hChange == INVALID_HANDLE_VALUE)
{
// do error stuff
return 1;
}
while(true)
{
// check if event is signaled
dwMessageId = WaitForSingleObject(hChange, 0);
if(dwMessageId == WAIT_OBJECT_0)
{
// process Event change
}
else if(dwMessageId == WAIT_FAILED)
{
// do error stuff
}
// request that the operating system signal a change notification handle
if(::FindNextChangeNotification(hChange) == 0)
{
// do error stuff
}
Sleep(pThisObject->m_dwInterval);
}
|
|
|
|
|
Hi all,
I'm trying to develop a visual report writer and ran into a few problems. First of all, I want to include metafile support. I want to play with the metarecords, but can't find any sample code. There used to be a sample in MSDN (Metafile GDI sample in SDK, named MFEDIT), but the source files seemed to be removed. Does anybody knows where I can find these sources, or other sample code ?
Second problem, I want to paint the contents of a rich text control in a metafile DC without using FormatRange/DisplayBand, because this simply creates a bitmap and clips it to the metafile DC. I want the metafile DC to contain all GDI calls from the rich text control.
Can anybody help me ?
When report writer is finished, I'll post it on the codeproject site.
Thx,
Danny.
|
|
|
|
|
Hi, I have two questions:
1-I like to know if there's any function in MFC that returns the point (CPoint) on a bmp image.
2- I have a bunch of bmp files , and i like to locate the point that the pixl intensity have changed, ( ex: from white to black),,, does anyone know how to do that?
thanks
Ehsan
Ehsan Behboudi
|
|
|
|
|
You can do it with GetPixel/SetPixel, after selecting the bitmap into a DC, but it is *slow*. Much better to use a DIBSection ( class wrappers here, and as part of paintlib ( www.paintlib.de )), which gives you a pointer to the data, which you can then traverse and check for value changes.
What do you mean by a CPoint ? I assume you mean the pixel value there ( GetPixel ) but when your question does not read that way. If it's something else, please clarify and I will try to answer.
Christian
#include <std_disclaimer.h>
|
|
|
|
|
Hi, I have two questions:
1-I like to know if there's any function in MFC that returns the point (CPoint) on a bmp image.
2- I have a bunch of bmp files , and i like to locate the point that the pixl intensity have changed, ( ex: from white to black),,, does anyone know how to do that?
thanks
Ehsan
Ehsan Behboudi
|
|
|
|
|
Does anyone have a guideline that I can use on how to create an NT service that will allow use of MFC? If so can you please point me in the right direction.
Thanks!
Roger Printy
Software Engineer
TeraNex
Orlando, FL
|
|
|
|
|
Please, but please, do not use MFC on services...
First of all a service can create a window on another desktop than yours... I'm wondering what MFC will do in CWnd::FromHandle...
Cristian 'Sardaukar' Amarie
Zero Software Group
|
|
|
|
|
If you just need to use MFC database classes in your service, you can check these Knowledge Base articles for more info:
Q152696
Q156138
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Most likely, you don't need to write your own NT service. Just write you program in MFC and uses a special NT service to run it.
|
|
|
|
|
Hi,
We use CreateEvent() API to create event object.
This Event Object is recognized in the local system.
When it comes to Remote Systems is there any API similar to CreateEvent() for notification?
Thanks.
Yamuna.E.
|
|
|
|
|
I have a constructor defined as shown:
CFirstClass:: CFirstClass(const CFirstClass &myClass)
{
// some code
CFirstClass* pAnotherFirstClass;
pAnotherFirstClass= &myClass; // error on this line
// code
}
The error states:
error C2440: '=' : cannot convert from 'const class CRegisterItem *' to 'const int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
pls help.
|
|
|
|
|
This sort of error often means a missing #include file, in this case the one for CRegisterItem. It's hard to figure out, because from your code I have no idea what a CRegisterItem *is* ( I don't believe it's MFC, although I've been wrong before ).
Christian
#include <std_disclaimer.h>
|
|
|
|
|
Change
CFirstClass* pAnotherFirstClass
to
const CFirstClass* pAnotherFirstClass
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
I need a list of lists, something like:
CList[CList[CPoint,CPoint&],CList[CPoint,CPoint&]&]path;
(I've put [ and ] instead of less and greater sign because of HTML formatting.) How to do it
|
|
|
|
|
Try this:
typedef CList<CPoint, CPoint&> PointList;
typedef CList<PointList, PointList&> Path;
|
|
|
|
|
I've tried it before, it doesn't work.
|
|
|
|
|
Hi!
I have a very simple class used to display a checkbox, filled or not depending on if a task is finished. I the dialog editor, I set the SS_REALSIZEIMAGE property. This works great, until the image is set using SetIcon. After that call, CStatic formats the icon as a 32x32, which I don't like.
I've tried to use ModifyStyle and RedrawWindow after the call to SetIcon, but no success.
My code:
void CTaskFinishedCheck::SetFinished(BOOL bFinished)
{
if ( bFinished )
{
SetIcon( hCheckedIcon );
}
else
{
SetIcon( hUncheckedIcon );
}
}
Someone who knows?
|
|
|
|
|
Hi!
Use the ::LoadImage API function instead of CWinApp::LoadIcon(). For example:
HINSTANCE hInst = AfxGetInstanceHandle();
hIcon = (HICON) ::LoadImage(hInst, MAKEINTRESOURCE(IDI_FOOBAR), IMAGE_ICON, 16, 16, 0);
Hope this helps!
|
|
|
|
|
It did. Thanks. I must learn to read the whole Remark section.
|
|
|
|
|
Thx, I experienced the same problem using CStatic::SetIcon with dynamically loaded icon thru LoadIcon. The LoadIcon function seems to scale down any icon dimension back to system defaults (e.g. (32, 32)).
|
|
|
|
|
I am using this code to download a INET File
CFile ofile;
ofile.Open(_T("globe.gif"), CFile::modeWrite | CFile::modeCreate | CFile::typeBinary);
DWORD dread;
BYTE szBuff[1024];
//assumes URL names have been initialized
CInternetSession session("My Session");
CStdioFile* pFile = NULL;
pFile = session.OpenURL(_T("http://..."), 1, INTERNET_FLAG_TRANSFER_BINARY);
while ((dread = pFile->Read(szBuff,1024)) > 0)
{
ofile.Write(szBuff, dread);
}
delete pFile;
session.Close();
This code works alright but I with the code above if my laptop is away from my INET connection there is ASSERT or Exception in CStdioFile::Read() or CStdioFile::Close().
I have used the code below w/ CStdioFile before but w/ the code above CStdioFile::m_pStream seems to always be NULL.
CStdioFile StdioFile;
//use it
if(StdioFile.m_pStream != NULL)
{
FileSaver.Close();
}
So is there a quick way to this the return val of CInternetSession::OpenURL() w/out using TRY/CATCH Blocks or Exceptions. Please these for some reason get the best of me for now.
Thank you...
|
|
|
|
|
Hi
I like the idea of the __try/__finally block, where you can put all your clean up code in the one spot. I'm doing lots of ADO COM stuff... getting recordsets, etc., so I've got a catch(_com_error & e) handler. Is there anyway I can also have a __finally block?
All the MSDN stuff says is "MFC has no concept of termination handlers"
I know its possible to combine SEH and C++ exception handling by using the MFC class SEHException but this won't help me will it?
Thanks
Brendan
|
|
|
|