|
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
|
|
|
|
|
I wrote an OCX (that dynamically links MFC) using VC6. I wrote a test app that exercises the OCX in VC6, and the OCX appears to work fine.
I then wrote a test app in VB6, and this is where my sad story begins.
The OCX has some string properties, and these properties have Get/Set functions associated with them. If you're at all familiar with VB, you know that while you're running your app (from the VC6 IDE), you can hover your mouse over an OCX property name and a toolitip will popup giving you the value/contents of that property. For all but one property, this works fine, but when I try to hover the mouse over one of them (happens to be a string that holds an IP address), it *crashes the VB IDE*. After a little experimenting, I found that if I deleted the periods from the IP address in the string (did this in the OCX itself in the Get() function), it worked fine.
In the OCX, my Get/Set functions look like this:
CString m_sXXXProperty;
VARIANT CMyOcxCtrl::GetXXXProperty()
{
_variant_t vaResult;
vaResult = (const char*)m_sXXXProperty;
return vaResult;
}
void CMyOcxCtrl::SetXXXProperty(const VARIANT FAR& newValue)
{
_variant_t vTemp(newValue);
m_sXXXProperty = vTemp.bstrVal;
SetModifiedFlag();
}
First, I need to knbow if I'm doing anything wrong in the code above. Second, I need to know why in hell the dots in the IP address would cause a crash in VB.
In the VB test app, I cycle through a counter (also retrieved from the OCX) to retrieve other strings (using the same mechanism described above), but these strings are not properties. After I have called a retrieval function, the string in the VB app contains the expected text. However, when IO put that string into a listbox, all I get is the first character shown in the listbox.
I don't know much about VB, and really prefer not to know any more than I need to get this test app working as expected. I strongly suspect that my problem lies in the OCX functions that return the strings.
Keep in mind that this OCX works *fine* from the VC6 test application.
Any help would be appreciated.
|
|
|
|
|
Disclaimer: I've never written a COM object with MFC.
I think that some of the problem might be that you are passing a CString back to VB. VB is probably looking for a BSTR. COM works with UNICODE, not ascii, so that may be the first problem: The result is getting turned into a bunch of non-ascii UNICODE characters. Since Unicode is looking for a 16-bit null character, VB is probably not finding one and is blowing up. I don't know why this would work in C++.
I don't know if MFC does any conversions or not...take a look at the _bstr_t data type and break out the USES_CONVERSION and associated macros (OLE2T etc).
If you are only seeing the first character, that is likely some sort of Unicode / ascii conversion problem. COM works with Unicode. If the Unicode is converted to ascii without "proper conversion", it will display the first character only because the ASCII character set occupies the unicode positions 0-255.
The string "ABC" in unicode would have the byte pattern "A\0B\0C\0"
hope this helps.
If you need to pass strings to a VB app, why not use the BSTR type in your C++ component? That will map to a VB String variable directly.
"Harland Pepper, would you stop naming nuts" - Harland Pepper
|
|
|
|
|
I think that you need this....
CString m_strProperty = _T("");
STDMETHODIMP CCPerson::get_Property(BSTR *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
::SysFreeString(*pVal);
*pVal = m_strProperty.AllocSysString();
return S_OK;
}
STDMETHODIMP CCPerson::put_Property(BSTR newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
m_strProperty = newVal;
return S_OK;
}
Cheers.
Carlos Antollini.
|
|
|
|