|
Sure, I figured that was the easiest way to do it, I was just curious to know if there was a way to do it without waiting without relying on a separate thread. I will be opening and closing the drive several times during execution, but at the end of execution it ejects the CD for the user to remove and then quits. I would like to to eject, request that the user remove the CD, and then close the drive, but not wait for the drive after closing. Using a separate thread would still keep the program alive.
|
|
|
|
|
You have the mciSendCommand function.
With this function you can send command messages to MCI devices.
Carlos Antollini.
|
|
|
|
|
Hi
I have a function in my CView class, it takes a point, and returns the pixel intensity
when I compile it, there's no problem with it,, but there's no output file...
Can anyone help me out????
COLORREF CTestEdgeView::GetPoints( )
{
//this is the class which detects the firt point on the boarder
CClientDC dc(this);
test = dc.GetPixel(m_ptCenter.x +1 , m_ptCenter.y);
ofstream outfile ("ftest.out");
outfile <<"the intensity is: "<< test;
outfile.is_open();
return test;
}
Thanks
Ehsan Behboudi
|
|
|
|
|
Assuming the code works OK, I suspect "ftest.out" is being generated in the default directory (whatever that may be at run time). You might want to retry using a fully qualified filespec like "C:\\ftest.out".
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Is it possible to build a string with a class name and then create a C++ object of that type using some kind of rtti?
|
|
|
|
|
like this?
CBaseClass *pObj = NULL;
file.ReadString(className);
if (className == ClassA::SerializationName)
pObj = new ClassA;
else if (className == ClassB::SerializationName)
pObj = new ClassB;
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Make your objects COM objects. This way you can look them up based on the ProgID.
CLSIDFromProgID( L"ClassName", &clsid );
hr = CoCreateInstance( clsid, NULL, CLSCTX_ALL,
__uuidof(IClass), (void **) &pIClass );
This has the benefit of not needing to do some big if statement and adding a new string every time a new class is added.
Mike
|
|
|
|
|
You can pick some ideas from this article by Allen Holub:
http://msdn.microsoft.com/library/periodic/period96/S385.htm
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hi, I'm searchig for a routine for Authenticating users that dial to a NT4/2000 server, using RADIUS protocol, because users passe through a router that server is connected to it.
Please help me.
Regards,
HAMED.
|
|
|
|
|
Hello!
The fact: I created a program with mfc the access an .mdb database through a Regular MFC DLL
statically linked (i must do that). I add th DLL to my core program, i execute all the function,
like insertion of record, etc through the dialogs in DLL and the db in the DLL.
When i close the app i always get an error cause "the memory could not be read". All works fine
but this message box.
This, only when i use CDaoRecordset (that i must use instead of CRecordset), cause when i call a
function that show ie a message box, the memory error dont appear.. sigh
Anyone has an idea on how to kill this problem?
|
|
|
|
|
Have you tried rebuilding the entire project? ( i.e. Clean / Rebuild all )
If putting a MessageBox in will make the problem go away, then it is quite likely that the program's stack is corrupted. You also need to make sure that the .lib file you are statically linking with is up to date. i.e. build the dll first, then use the up to date .lib file to build the executable. The joys of statically linking.
"Harland Pepper, would you stop naming nuts" - Harland Pepper
|
|
|
|
|
I have a need to build a string as follows; "DOMAINNAME\USERID". In looking through the MSDN docs on networking it appears that I can use the API function NetWkstaUserGetInfo(). The docs say you have to include the header lmwksta.h. When you do this and compile, that header causes a compile error and inside it's documentation it says you must include netcons.h before you include this file. Unfortunately that file, netcons.h, does not exist on my PC anywhere. I've tried searching for variations on the name but have still come up empty. Does anyone have a thought on what might be broken? Or another way for me to put this particular string together. Thanks.
Chris
|
|
|
|
|
You only need the header lm.h and do not forget to link with the Netapi32.lib library.
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Thanks Carlos. With some more searching I found that there is a header file called lmcons.h. And in this file is a comment that it used to be called .. .. .. ta da. NETCONS.H
But I like your suggestion better. Just include lm.h and I should get all that will need. Thanks again.
Chris
|
|
|
|
|
How to detect the IP of the computer the programm is working on?
|
|
|
|
|
|
void CGetIPDlg::GetIP()
{
WORD wVersionRequested;
WSADATA wsaData;
char name[255];
CString ip;
PHOSTENT hostinfo;
wVersionRequested = MAKEWORD( 2, 0 );
if ( WSAStartup( wVersionRequested, &wsaData ) == 0 )
{
if( gethostname ( name, sizeof(name)) == 0)
{
if((hostinfo = gethostbyname(name)) != NULL)
{
ip = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list);
}
m_IP.SetWindowText(ip);
UpdateData(FALSE);
}
WSACleanup( );
}
}
<pre>
BLaZe
ICQ # 110244345
email : mpblaze@iquebec.com
|
|
|
|
|
How can I set the background color of a CView derived class(to black for example), without doing something silly like drawing a view-spanning rectangle in OnDraw()
cheers
Bilal
|
|
|
|
|
Handle the WM_ERASEBKGND message. Inside the handler, use PatBlt to fill the window with desired color.
BOOL CYourView::OnEraseBkgnd(CDC* pDC)
{
CBrush backBrush(RGB(0, 0, 0));
CBrush* pOldBrush = pDC->SelectObject(&backBrush);
CRect rc;
pDC->GetClipBox(&rc);
pDC->PatBlt(rc.left, rc.top, rc.Width(), rc.Height(), PATCOPY);
pDC->SelectObject(pOldBrush);
return TRUE;
}
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
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
|
|
|
|