|
Use a flag which you can control.
Greetings from Germany
|
|
|
|
|
Mike Doner wrote: Is there a windows call I can use that will tell me if the current process is running as a windows service
You can check whether one of the parent processes of this process is services.exe , user services are created via this process.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
I would like to store pointers to class member functions in an array (e.g. CTypedPtrArray) but I am having difficuly declaring, initialising and calling the functions. All functions are void fn(void) and are non-static.
Can anyone help please? 
|
|
|
|
|
Not really a good answer for you...
Pointers to member functions are nothing like a standard pointer, so it's unlikely you'll succeed. After all, they're really two pointers - they need a "this" pointer encoded also.
For an article that may help, I did a search for "member function pointer" on google, and this came up first:
Member Function Pointers and the Fastest Possible C++ Delegates[^]
A comprehensive tutorial on member function pointers, and an implementation of delegates that generates only two ASM opcodes!
Enjoy!
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
So do you have something like:
class MyClass;
typedef void (MyClass::*FNPTR)( void );
CTypedPtrArray<CPtrArray, FNPTR> arr;
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi Yes, amongs other things I tried that but I could not add the function pointers.
I tried to add them using
arr.Add(&MyClass::Fn1)
But the compiler wasnt happy:
error C2664: 'Add' : cannot convert parameter 1 from 'void (__thiscall MyClass::*)(void)' to 'void *'
What am I doing wrong?
Thanks
Tony
|
|
|
|
|
Hi,
Please any body provide the Migration approach document and any free Tools avialable from VC++ to .NET?.
Thanks
Gopinath
|
|
|
|
|
I've been scratching my head about this for a couple of days and am getting nowhere!
I upgraded my existing MFC app from VS2005 to VS2008. It uses ADO to connect to a sql server database. When compiled under VS2005 the connection to the server via the _ConnectionPtr interface opens virtually instantly.
When compiled under VS2008, the first time in my app takes around 30 seconds to return from _ConnectionPtr::Open, though if I close the connection and then open it again it's back to near instant. And the app runs 100% fine thereafter - no crashes, freezes etc..
It's literally freezing in the 'm_pConnection->Open(_bstr_t(m_strConnection),...' bit. I cannot trace deeper than that call!
I've created a simple console app with the bare minimum stuff needed for ADO with MFC and it connects instantly under VS2008. So I'm confused!
I'm thinking it must be something in my project settings. Also, my app uses a non-standard byte alignment for historical reasons, but it did under VS2005 and connected near instantly.
Any suggestions would be very gratefully received! Thanks!
Pete
|
|
|
|
|
Hi,
I am using VC++ 2005 with SP1 compiler for my project. The development is being done on Windows XP Pro + SP2 machine but the application is supposed to run on all platforms from Windows 2000 to Windows 2008. The application is a typical MFC application with one executable and many DLL files.
Now the query, compiling and running the application on my machine has no issues. However to run the application on the Windows Vista or 2008 I need to have either Visual C++ 2005 SP1 redistributable installed on the target machine or I should be using building the application with SxS assembly isolation in mind and provide the correct manifest for the executables and dll's (either embed it in the binaries or have them as separate file). Also I am relying on VC to generate/embed the manifest file on its own i.e. I am not supplying manifest file explicitly.
So while building the application I have chosen to embed the manifest file and set use isolation linker option. I was hoping that it will work properly, but unfortunately it didn't. When I checked I found that the manifest file embedded in one of the Dll's has different information than other DLL's due to which the application could not load the dependency properly.
For this particular DLL the embedded manifest file looks like this
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.762" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.MFC" version="8.0.50727.762" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50608.0" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.MFC" version="8.0.50608.0" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>
I have Microsoft.VC80.CRT and Microsoft.VC80.MFC manifest files along with the proper versions of the DLL files in the output directory.
I am unable to figure out from where the VC linker is referencing the MFC and Runtime libraries with the following version <b>Microsoft.VC80.CRT" version="8.0.50608.0"</b>.
A quick scan of the dll in question does not show me any dependency on MFC or VC runtime libraries with version 8.0.50608.
Can someone please help me in identifying the location from where the VC linker picks up the manifest file to be generated?
If this is not the correct forum please do let me know
I am waiting for resolution and help in understanding the issue from all the brilliant guys out there.
Thanks and Regards

|
|
|
|
|
The different versions are one is the original version, and the other is the version of the SP1 of VS2008. You to download and install the vc_redist.exe for VS2008 SP1 on the target machines.
Thats it
Greetings from Germany
|
|
|
|
|
Hi,
I have checked at Microsoft site and as per the site the version of file for VC++ 2005 redistributable binaries is 8.0.50727.42 and the file version for VC++ 2005 SP1 redistributable binaries is 8.0.50727.762
And there is no redistributable package of VC++ 2005 with or without SP1 for Window 2008. For VC++ 2008 the MFC and CRT version is 9.0.21022.8
The issue is that why is the linker embedding a manifest file for only 1 particular DLL with MFC and CRT libraries as 8.0.50608.0 and from where it is picking that information. I think it should have used this information either for all DLL's/EXE or none of the DLL's/EXE.
And as I have mentioned earlier, the Dependency Scanner tool also does not show any dependency of MFC or CRT binaries with file version 8.0.50608.0. So I am confused here.
On the machine I am developing I have never installed any Beta or RC version of Visual C++ 2005.
Probably installing the redistributable binaries of VC++ 2005 SP1 on the target machine may solve this issue, but that is not the solution I am looking for. Isn't the purpose of using manifest file for EXE/DLL files is to make sure that your application is not affected and always use the same dependencies if someone removes the redistributable binaries from the target machine?
Thanks

|
|
|
|
|
I guess might have installed some hot fix for VC++ and it updated the binaries. It happened to me with VC++ 2008 and I was unable to figure this out for a while. How to determine which DLL/EXE is linked with that version? If you don't have too many DLL's the use good old http://www.dependencywalker.com/[^] to find which modules each DLL depends on. If it depends on CRT or MFC check the version by checking the properties of that DLL in depends.
-Saurabh
|
|
|
|
|
Also by any chance is any of your DLL a shell extension? Or perhaps you use a 3rd party library it uses the newer version of CRT or MFC.
-Saurabh
|
|
|
|
|
I managed to make my application totally standalone in the sense that now it can be simply copied and executed on any target machine without worrying whether the proper side-by-side assemblies are installed on target machine or not.
For those interested here is link which really helped me
http://blog.kalmbach-software.de/2008/05/03/howto-deploy-vc2008-apps-without-installing-vcredist_x86exe
Though the article is for VC2008 but it is applicable to VC2005 as well.
However there is a small issue with the method mentioned. If your application is dependent on a 3rd party DLL which has embedded manifest file then the method will not work. In such case probably installing the redistributable will be a better idea.
Thanks

|
|
|
|
|
I want to display a bitmap that has an alpha chanel for the background.
How can I make the alpha chanel transparent?
I tried using AlphaBlend() but it doesn't work.
Any suggestions?
danginkgo
|
|
|
|
|
|
I can't figure it out...
What shall I use to dispaly the bmp?
danginkgo
|
|
|
|
|
Hi,
Here is an article explaining alpha blending:
Alpha Blending using GDI+[^]
Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
I am using GDI.
Is alpha blending posible only with GDI+ ?
I want to blend only the background.
Thank You for the answers.
danginkgo
|
|
|
|
|
|
danginkgo wrote: I tried using AlphaBlend() but it doesn't work.
How did you do this? What values did you use in the BLENDFUNCTION struct?
Is the bitmap 32bpp? What does "doesn't work" mean.
|
|
|
|
|
This is my BLENDFUNCTION struct:
<br />
BLENDFUNCTION blendF; <br />
blendF.BlendOp = AC_SRC_OVER; <br />
blendF.BlendFlags = 0; <br />
blendF.SourceConstantAlpha = 255; <br />
blendF.AlphaFormat = AC_SRC_ALPHA; <br />
The bitmap is 32 bpp with an alpha chanel.
When I display the image using AlphaBlend() function the image looks the same as when I displayed it using BitBlt().
I want the background (wich has an alpha chanel) to be transparent.
Is it posible using this function?
danginkgo
|
|
|
|
|
danginkgo wrote: When I display the image using AlphaBlend() function the image looks the same as when I displayed it using BitBlt().
Then all the alpha channel values must be 255.
danginkgo wrote: Is it posible using this function?
Yes. Try something like this, creating and rendering your own 32bpp ARGB bitmap:
LONG lImageWidth = 640;
LONG lImageHeight = 480;
WORD wBitsPerPixel = 32;
LONG lStride = lImageWidth * 4;
BYTE* pBitmapBits;
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = lImageWidth;
bmi.bmiHeader.biHeight = lImageHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = wBitsPerPixel;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = lStride * lImageHeight;
HDC hdcMem = ::CreateCompatibleDC(0);
HBITMAP hBitmap = ::CreateDIBSection(hdcMem, &bmi, DIB_RGB_COLORS, (void**)&pBitmapBits, NULL, 0);
if (hBitmap)
{
memset(pBitmapBits, 0, bmi.bmiHeader.biSizeImage);
RGBQUAD *pCurPixel = (RGBQUAD *)pBitmapBits;
int PixelCount = lImageWidth * lImageHeight;
while (PixelCount > 0)
{
(*pCurPixel).rgbRed = 0x00;
(*pCurPixel).rgbGreen = 0x00;
(*pCurPixel).rgbBlue = 0xA0;
(*pCurPixel).rgbReserved = 0x80;
pCurPixel++;
PixelCount--;
}
HGDIOBJ hOldBitmap = ::SelectObject(hdcMem, hBitmap);
HDC hClientDC = ::GetDC(*this);
HPEN hPen = ::CreatePen(PS_SOLID, 10, RGB(255,0,128));
HGDIOBJ hOldPen = ::SelectObject(hClientDC, hPen);
::MoveToEx(hClientDC, 0, 0, NULL);
::LineTo(hClientDC, 650, 490);
::SelectObject(hClientDC, hOldPen);
::DeleteObject(hPen);
BLENDFUNCTION bf;
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
bf.SourceConstantAlpha = 0xFF;
bf.AlphaFormat = AC_SRC_ALPHA;
::AlphaBlend(hClientDC, 0, 0, lImageWidth, lImageHeight,
hdcMem, 0, 0, lImageWidth, lImageHeight, bf);
::ReleaseDC(*this, hClientDC);
::SelectObject(hdcMem, hOldBitmap);
::DeleteObject(hBitmap);
}
::DeleteDC(hdcMem);
|
|
|
|
|
Hi,
Is there a way I could add a browser window - like control, on my dialog?
Thank you,
AJ
|
|
|
|
|
In VC6 IDE, you have option to add ActiveX controls via your resource editor.
Take menu Projects->Add to project->Components and Controls will bring a dialog.
Double click on Registered ActiveX Controls and select Microsoft Web Browser from the list of controls displayed.
This will ask you permission to add support of IE into your application. Select button OK will copy the required header files into your project folder.
Now take the resource editor, where you can see a new control appeared for inserting IE as a control.
Drag and drop it into your dialog and enjoy.
|
|
|
|