|
How to implemet MAPIGUID ?example
dadsadasd
|
|
|
|
|
Other than mapiguid.h, I do not know what MAPIGUID is. Can you explain a bit further?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thank u for reply.Part of My Apps I want run MAPIUID's? ie mean Access the OutLookExpress Dialog Boxes,Creating New Accounts,Get Accounts .. etc dialogboxes?
I want how run Internet Connection Wizard?
Pl Give an Example.
dadsadasd
|
|
|
|
|
asv wrote:
Access the OutLookExpress Dialog Boxes,Creating New Accounts,Get Accounts .. etc dialogboxes?
Unless Outlook Express exposes an automation interface (like Outlook does), I'm not sure how you'd do this.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I had problem with LUNCHWIZARDENTRY? I was unable run apps?
satyavasu
|
|
|
|
|
Hi,
I'll try to make this as straight forwards as possible I'll describe the situation I want to create and the problem I'm facing as a consequence.
I have a simple MFC-App (MfcApp.exe ). It has a resource-DLL (MfcApp-Res.dll ) which it maps using AfxSetResourceHandle .
I want to build an MFC-Extension-DLL (MfcExt.dll ) with new controls in it. I want this Extension-DLL to use resources from an additional Dll (MfcExt-Res.dll ).
What I would like to have:
* MfcExt.dll loads resources from MfcExt-Res.dll
* MfcApp.exe loads resources from MfcApp-Res.dll and from MfcExt-Res.dll (without explicitly stating MfcExt-Res.dll anywhere, just by linking to MfcExt.dll )
But,
Once the MFC-App will use the MFC-Extension-DLL, I expect a mess, why ?
MSDN docs state that the MFC-App and Extension-DLL will use the same resource-dll handle.
How can this be handled cleanly ?
What is the percise function of CDynLinkLibrary in this case ?
Thanks for the help,
|
|
|
|
|
The CDynLinkLibrary is a list of libraries loaded dynamically during the run of the MFC program. When the MFC program requires a resource, it will traverse the chain of the dll in the list and stop once it finds the resource that matches. If you want the MfcExt.dll to only use resources from the MfcExt-Res.dll, you have two easy choices as I see it:
1. Always adjust the AfxSetResourceHandle() prior to any calls within MfcExt.dll that might load resources to the MfcExt-Res.dll and then set it BACK once you are done loading resources, which will cause it to load resources from the desired resource dll
2. Only use resouce identifiers in the MfcExt-Res.dll that do not overlap any within the MfcApp-Res.dll module. When the MfcApp.exe tries to load a resource, it will check MfcApp-Res.dll and then search in MfcExt-Res.dll. The MfcExt.dll will do the same search, but it will only find the resources in the MfcApp-Res.dll.
I prefer to PLAN my resource utilitization, assign numerical identifier ranges, and go with option 2 myself. It saves tracking down resource loading and a lot of busy work associaed with option 1.
|
|
|
|
|
I have a activex control which expects HDC as one of its arguments.
In my program I have my window dc which I want to pass it on to this function, now the issue is how do I convert the HDC to long.
If this is not possible, how should one go about achieving this, I dont have access to the source of the activex.
Thanks,
Kannan
|
|
|
|
|
|
|
Ok, i have a very serious problem (allthough it is probably just due to something rediculous i overlooked like these problems usually are). I have been programming with winsock and windows for a few years now so i like to think i know what i'm doing. During these years i have always kind of avoided MFC, so now i thought, why not make it easy on myself and use MFC.
This is the situation, and i will try to sketch it as clearly as possible:
I have an MFC dialog based application, one main dialog window based on the CDialog class and then i have a socket class based on CSocket in which i override the OnClose(), OnConnect(), OnReceive() and OnSend() methods which all call a function in my main Dialog class (using a parent pointer which i set in OnInitDialog() of my main dialog). Now.. the application needs to connect to a server when a button is pressed or whatever, but because i want to be able to tell when a connection fails (either refused or timed out) i keep the socket in blocking mode (which is the default for CSockets anyway) and try to connect. Then when the Connect() method succeeds (returns TRUE) then i use AsyncSelect() on the socket to register to right notifications (FD_CLOSE, FD_CONNECT, FD_READ and FD_WRITE). So of course OnConnect() will never be called, thats obvious, because the connection was established when the socket was still in blocking mode. But the OnReceive() event should work, and it does. Only the ABNORMALLY WEIRD (to me anyway) thing is.. well after the connection succeeded i send a string to the server, and the server replies with two strings (each command is terminated by '\n') which i parse in OnReceive() like this:
char pText[4096];
CString strTemp;
int nResult = m_hSocket.Receive(pText, sizeof(pText));
if (SOCKET_ERROR == nResult)
{
MessageBox("An error occured while receiving data...",NULL,MB_ICONERROR);
}
else
{
pText[nResult] = NULL;
strTemp = CString(pText);
for(int i=0;i<strTemp.GetLength();i++)
{
if(strTemp[i]=='\n')
{
OnReceiveCommand(szLineBuffer);
szLineBuffer.Empty();
}
else
{
szLineBuffer += strTemp[i];
}
}
}
Where szLineBuffer is just a global variable to my class which is used to store text when a command did not fit into one received chunk. Now notice where i put MESSAGE 1 and MESSAGE 2. This is the odd part, when i uncomment MESSAGE 1 to display a messagebox, and i run my app, when it receives the two commands from the server it is supposed to go like this:
The asynchronous socket calls my OnReceive function because there is data to be read, so my OnReceive reads the data then parses it depending on how many lines there are. When i run it, i get two messageboxes, the first one for the first command, then AFTER that one another one for the second command (the way it should be). BUT when i uncomment MESSAGE 2 this odd thing happens, which is what causes the error in my app which i cant seem to resolve:
When i uncomment MESSAGE 2 and run it, I GET TWO MESSAGEBOXES SIMULTANEOUSLY. O.O I'm completely stunned by this.. I have no explanation whatsoever. I've thought on it for hours and hours and cannot come to any sensible explanation. Because in my mind, the message pump of the dialog cannot continue untill OnReceive() has completed, and yet somehow, it manages to display the two messageboxes at once.. Now, i did realise that MFC is probably using a dummy window for the asynchronous messages to then pass them on the overrided methods, so i tried Sending messages to my main dialog window using SendMessage() in the socket class, and same effect. Of course that was rather stupid because it doesnt make a difference since the message loop of the dummy window the MFC socket class uses should block also on calling the methods from my dialog.
I hope this shows u what my problem is, and how nasty and weird it seems to me.. and of course most of all i hope that someone can explain to me why it is doing this! Or i will have a lot of hair to loose over this one yet.
Thanks to anyone who can help.
Kuniva
--------------------------------------------
|
|
|
|
|
BTW, even if the Receive() method on the socket somehow lets the CSocket class know that the reveive has been handled and that it can now handle other events, i still dont see how my scenario can happen since the code of the CSocket class should still be frozen when it calls the OnReceive method of my dialog.
Kuniva
--------------------------------------------
|
|
|
|
|
Your underlying problem is that the MessageBox API call has a message pump within it.
If you already know how to use WinSock, stick to that. The CSocket and CAsyncSocket classes are generally considered to be broken. You may find the Winsock Programmer's FAQ[^] helpful.
Do your comms on a separate thread and post notification messages back to the UI thread using PostMessage . If you want the comms thread to block waiting for a response from the UI, try SendMessageTimeout instead.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Uhm, thank you for this explanation, i had read before that the Socket classes from MFC were considered to be a bit faulty, but never knew they were considered broken.. hmm. And i have read the Winsock Programmer's FAQ already more than once . I know my way around the Winsock API, just not MFC..
What is very interesting is this message pump of the MessageBox, i'm afraid i don't quite understand.. I mean, if the messagebox is a modal dialog and it has it's own message pump, what difference does it make? As long as the messagebox is displayed the message pump of the main dialog is still frozen and cannot process messages isn't it? If you could explain, because it is still bugging me...
Another thing i would like to mention for everyone who ever ran into the same program is this: I was able to fix my problem by Switching the socket into blocking mode at the start of my OnReceive method like this:
DWORD dw = (DWORD)0;
m_hSocket.AsyncSelect(0);
m_hSocket.IOCtl(FIONBIO,&dw);
And switching it back to asynchronous mode like this:
if(m_hSocket!=INVALID_SOCKET)
m_hSocket.AsyncSelect(FD_CLOSE | FD_CONNECT | FD_READ | FD_WRITE);
The condition is just there because if certain data is received i might call Close() on the socket and if u try AsyncSelect() after a Close() u get an assertion failure.
Thank you very much for your reply.
Kuniva
--------------------------------------------
|
|
|
|
|
Because the message box runs a message loop, your code can go re-entrant if another thread posts or sends messages to your window, or if a timer fires. I think that's what you were seeing.
Part of the issue is that sent messages are always processed within the GetMessage call of the message loop. The other part is that the message loop inside MessageBox appears to pump messages for all windows, not just the message box window itself.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
How can I obtain the size of a CFile in bytes?
|
|
|
|
|
How about the GetLength() method?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Do you want to get the file length or CFile object length?
If you want to get the length of special file, you can use GetLength() to obtain it.
But I recommend you to use CFindFile, the class can help you to get any file's length include locked/system/hidden/archive and so on.
Good luck.
Andy Xia
2004.5.4
|
|
|
|
|
the size of the object is easy... sizeof()
Don't try it, just do it!
|
|
|
|
|
I wanted the length of the acutal file, not the object.
In the end I did this.
DWORD dwFileSize = myFile.SeekToEnd( );
myFile.SeekToBegin( );
It works el perfecto (same as the old stdio method).
|
|
|
|
|
I have a grayscale image of 100x100px, where the top half is gray (pixel value=128) and the bottom half is black (value=0); however when i plot it to screen, it comes flipped. Why is that? Can anyone help? Here is the source; The result on screen is black followed by gray, which is not what i want. Why is it flipped?
void CPopUpDlg::OnButton1()
{
BITMAPINFO *m_pBmiImage;
CDC *pDC;
BYTE *m_pImg;
pDC =this->GetDC();
DWORD bitmapInfoSize;
int i;
int Width=100;
int Height=100;
//image of 8bit , 100x100pixels
int m_iSize = Width * Height;
m_pImg = new BYTE[m_iSize];
// Bitmap info structure for the image
bitmapInfoSize = sizeof(BITMAPINFO) + 255*sizeof(RGBQUAD);
m_pBmiImage = (BITMAPINFO*)new BYTE[bitmapInfoSize];
m_pBmiImage->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
m_pBmiImage->bmiHeader.biPlanes = 1;
m_pBmiImage->bmiHeader.biBitCount = 8;
m_pBmiImage->bmiHeader.biCompression = BI_RGB;
m_pBmiImage->bmiHeader.biSizeImage = 0;
m_pBmiImage->bmiHeader.biXPelsPerMeter = 0;
m_pBmiImage->bmiHeader.biYPelsPerMeter = 0;
m_pBmiImage->bmiHeader.biClrUsed = 0;
m_pBmiImage->bmiHeader.biClrImportant = 0;
m_pBmiImage->bmiHeader.biWidth = Width;
m_pBmiImage->bmiHeader.biHeight = Height;
//Set the color table as just grays.
for (i = 0 ; i < 256 ; i++) {
m_pBmiImage->bmiColors[i].rgbBlue = (BYTE)i;
m_pBmiImage->bmiColors[i].rgbGreen = (BYTE)i;
m_pBmiImage->bmiColors[i].rgbRed = (BYTE)i;
m_pBmiImage->bmiColors[i].rgbReserved = 0;
}
//first half of the image is gray
for(i=0;i<100*50;i++) m_pImg[i]=128;
//second half of the image is black
for(i=100*50;i<100*100;i++) m_pImg[i]=0;
//Plot to screen
SetDIBitsToDevice(pDC->m_hDC,
100,
100,
Width,
Height,
0,
0,
0,
Height,
m_pImg,
m_pBmiImage,
DIB_RGB_COLORS);
delete[] m_pImg;
delete m_pBmiImage;
}
|
|
|
|
|
its a complete guess, might not work but worth a try
m_pBmiImage->bmiHeader.biHeight = -Height;
specify negative height
i can't even remember what my point is now, but anyway, i'm correct
Barring unforeseen acts of God and Adminstrators, my server will be up tomorrow. I'm more worried about the Adminstrators.
|
|
|
|
|
Thanks, works just fine! Now the image plots correctly! Thanks a lot for the prompt reply!!
|
|
|
|
|
I downloaded the IPC Workshop project from 'The Code Project' but I get the following error:-
c:\IPC\IPCWorkshop\IPCWorkshopDlg.cpp(110): error C2440: 'static_cast' : cannot convert from 'void (__thiscall CIPCWorkshopDlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
.... when I try and build the project with Visual Studio .Net.
Does anyone know the compiler setting to get rid of the error?
|
|
|
|
|
MFC 7.0 has enhanced message map macros which catch errors in the return value; MFC 6.0 did not check you used the correct return type.
Change the declaration of whichever function is causing the problem (the source line will show an ON_MESSAGE macro) so that the return type is LRESULT rather than void .
On some systems, this could cause run-time errors.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|