|
I checked the dlls which I am using is of 64 bit.
Any other possible reason?
|
|
|
|
|
john5632 wrote: Any other possible reason? I assume yes, but since the error code does not give us any useful detail I suggest you pass it up the line to Microsoft.
|
|
|
|
|
Please check the return value again. 0x800700C1 seems to be wrong. The high word 0x8007 indicates that it is a normal Windows error code. But 0xC1 / 193 is ERROR_BAD_EXE_FORMAT : '%1 is not a valid Win32 application' which makes no sense here.
|
|
|
|
|
it makes sense if the process is 32-bits and is trying to load a 64-bit DLL.
|
|
|
|
|
Hello. I have a cursor conundrum. I am developing a custom control and one feature I want this custom control to have is the ability to be able to rearrange its appearance by dragging and dropping one part of it to another. The way I decided I would do this would be to:
1) Convert the selected area into a bitmap
2) Use the bitmap from 1) as the cursor until the drop point is selected.
3) Redraw the control in the new arrangement.
I am not worried about step 3). That should be trivial - it won't involve anything I haven't achieved already in my code concerning bitmaps or device contexts. However, I have a conundrum concerning step 2). I have achieved what I want to achieve but only if I save the bitmap to a file first then reload it as a cursor! What I am looking for here is a way of obtaining the bitmap data and converting it directly into a cursor. Clearly my problem stems from having cobbled together samples of code from various sources without properly understanding what is going on -
So I call the image capuring function on clicking the mouse...
void CScrollBarEx::OnLButtonDown(UINT inFlags, CPoint inPoint) {
...
CaptureAnImage(sliderVector[m_currentSlider-1].sliderRect);
...
}
and then you can see where I have edited out the code where I try and use the HBITMAP used to subsequently make a .bmp file to make the cursor - doing this always produces a black rectangle as the cursor. However- when I save that HBITMAP to .bmp file, then reload it into memory and use that to make a cursor - it works perfectly!
int CScrollBarEx::CaptureAnImage(RECT sliderRect)
{
HDC hdcWindow;
HDC hdcMemDC = NULL;
HBITMAP hbmScreen = NULL;
BITMAP bmpScreen;
HBITMAP m_hAndMask;
HBITMAP m_hXorMask;
hdcWindow = (GetDC())->GetSafeHdc();
hdcMemDC = CreateCompatibleDC(hdcWindow);
if(!hdcMemDC)
{
goto done;
}
RECT rcClient;
GetClientRect(&rcClient);
hbmScreen = CreateCompatibleBitmap(hdcWindow, sliderRect.right-sliderRect.left, sliderRect.bottom-sliderRect.top);
if(!hbmScreen)
{
goto done;
}
SelectObject(hdcMemDC,hbmScreen);
if(!BitBlt(hdcMemDC,
0,0,
sliderRect.right-sliderRect.left, sliderRect.bottom-sliderRect.top,
hdcWindow,
sliderRect.left,sliderRect.top,
SRCCOPY))
{
goto done;
}
GetObject(hbmScreen,sizeof(BITMAP),&bmpScreen);
BITMAPFILEHEADER bmfHeader;
BITMAPINFOHEADER bi;
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = bmpScreen.bmWidth;
bi.biHeight = bmpScreen.bmHeight;
bi.biPlanes = 1;
bi.biBitCount = 32;
bi.biCompression = BI_RGB;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
DWORD dwBmpSize = ((bmpScreen.bmWidth * bi.biBitCount + 31) / 32) * 4 * bmpScreen.bmHeight;
HANDLE hDIB = GlobalAlloc(GHND,dwBmpSize);
char *lpbitmap = (char *)GlobalLock(hDIB);
GetDIBits(hdcWindow, hbmScreen, 0,
(UINT)bmpScreen.bmHeight,
lpbitmap,
(BITMAPINFO *)&bi, DIB_RGB_COLORS);
HANDLE hFile = CreateFile(L"capture.bmp",
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
DWORD dwSizeofDIB = dwBmpSize + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
bmfHeader.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + (DWORD)sizeof(BITMAPINFOHEADER);
bmfHeader.bfSize = dwSizeofDIB;
bmfHeader.bfType = 0x4D42;
DWORD dwBytesWritten = 0;
WriteFile(hFile, (LPSTR)&bmfHeader, sizeof(BITMAPFILEHEADER), &dwBytesWritten, NULL);
WriteFile(hFile, (LPSTR)&bi, sizeof(BITMAPINFOHEADER), &dwBytesWritten, NULL);
WriteFile(hFile, (LPSTR)lpbitmap, dwBmpSize, &dwBytesWritten, NULL);
GlobalUnlock(hDIB);
GlobalFree(hDIB);
CloseHandle(hFile);
HBITMAP hBMP;
HPALETTE palette;
LoadBitmapFromBMPFile(L"capture.bmp", &hBMP, &palette);
m_hCursor = CColorCursor::CreateCursorFromBitmap(hBMP,RGB(0,0,0),0,0);
::SetCursor(m_hCursor);
done:
DeleteObject(hbmScreen);
DeleteObject(hdcMemDC);
DeleteObject(hdcWindow);
return 0;
}
and
HCURSOR CColorCursor::CreateCursorFromBitmap(HBITMAP hSourceBitmap,
COLORREF clrTransparent,
DWORD xHotspot,DWORD yHotspot)
{
HCURSOR hRetCursor = NULL;
do
{
if(NULL == hSourceBitmap)
{
break;
}
HBITMAP hAndMask = NULL;
HBITMAP hXorMask = NULL;
GetMaskBitmaps(hSourceBitmap,clrTransparent,hAndMask,hXorMask);
if(NULL == hAndMask || NULL == hXorMask)
{
break;
}
ICONINFO iconinfo = {0};
iconinfo.fIcon = FALSE;
iconinfo.xHotspot = xHotspot;
iconinfo.yHotspot = yHotspot;
iconinfo.hbmMask = hAndMask;
iconinfo.hbmColor = hXorMask;
hRetCursor = ::CreateIconIndirect(&iconinfo);
}
while(0);
return hRetCursor;
}
I have used code from the following sources...
HOWTO: How To Use LoadImage() to Read a BMP File
at http://support.microsoft.com/kb/158898
and
Creating a color cursor from a bitmap
at Creating a color cursor from a bitmap
In the last article the author warns against making a cursor outside of the standard cursor sizes but this doesn't explain why the code works when loading a cursor from file but not when using the bitmap directly!
modified 21-Feb-13 4:05am.
|
|
|
|
|
How Print multiple copies with printdlg in MFC
|
|
|
|
|
|
I create printdlg :CPrintDialog(FALSE, PD_ALLPAGES | PD_COLLATE | PD_NOSELECTION | PD_HIDEPRINTTOFILE);
when I input copies>1,It still print one.
DEVMODE *dm= (LPDEVMODE)::GlobalLock(pInfo->m_pPD->m_pd.hDevMode);
the dm->dmCopies = 1;
|
|
|
|
|
|
|
I'm creating an application in which I'll have to load an image using open file dialog.
there may be any image from system and will have to display that. I'll not have to save my image in resource because its not defined which image is going to be displayed.
Application is win32 API not MFC.
How can I do it?
Thanks!
|
|
|
|
|
|
|
It's completed.
Now I'm trying to load image from memory buffer.
Are you having any idea?
|
|
|
|
|
You can copy the buffer to a global memory buffer, then use CreateStreamOnHGlobal [^] to get the image buffer as a stream, which can then be passed to Image.FromStream [^]. The following should (I hope) help to clarify it:
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
PVOID pvData = GlobalLock(hGlobal);
CopyMemory(pvData, pImageData, dwFileSize); GlobalUnlock(hGlobal);
IStream* pStream;
HRESULT hResult = CreateStreamOnHGlobal(hGlobal, TRUE, &pStream);
Image* pImage = Image::FromStream(pStream);
pStream->Release();
RectF destRect; Graphics graphics(hDC);
graphics.DrawImage(pImage, destRect);
delete pImage;
|
|
|
|
|
Hi Toms, you could use the CxImage library - which allows you to specify the image bits when constructing an image, or you could use CreateDIBSection to create a bitmap using the image data you already have, then display it using an HDC.
|
|
|
|
|
Although MFC only supply very little controls, it will need too much time to make its own directUI controls.
I donot know if anyother advantage if using directUI.
|
|
|
|
|
When I used CFileDialog in MFC Dialog Project, it ran correctly. But when CFileDialog is used in DLL Projects(MFC Dll and Win32 Dll) it didn't run.
In detail, DoModal() function didn't run. program stopped.
Please Help me.
Thank you for reading my question.
|
|
|
|
|
LeeUnSong wrote: program stopped. You need to provide more detail than this, we cannot guess what your code is doing.
|
|
|
|
|
Thank you for your kindness. sorry for my poor english.
I created project with "Regular Dll with MFC statically linked".
Then I added new class "CMainDlg" to project. Of course, this class has resource "IDD_MAINDLG".
I put button control on my dialog and made event function "CMainDlg::OnBnClickedOpenfile".
After that, I added code as follow.
void CMainDlg::OnBnClickedOpenfile()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CFileDialog OpenDlg(TRUE);
if (OpenDlg.DoModal() != IDOK)
{
AfxMessageBox("Clicked Cancel");
return;
}
AfxMessageBox("Clicked OK");
}
Build my project and loaded my dll file from other project.
Then MainDlg appeared.
But after clicking "OpenFile" button, no messagebox appeared.
What is wrong in my code???
|
|
|
|
|
LeeUnSong wrote: What is wrong in my code? I am not sure. The best solution is to use your debugger to step through the code and check what happens at each line.
|
|
|
|
|
I need help deciphering how to use manipulators to put together this output statement correctly. (setprecision, setw, right...etc.). This is just one small part of my homework, but if I can see this worked out I should be able to put the rest together myself. My professor has no communication or teaching skills and leaves me confused.
Output fourth with four digits, with the sign shown at the left, and the value right aligned. The decimal point must also appear.
Here is the program my professor is having us go by:
cout << "Enter bool, int, long, float, float, and double values: ";
cin >> first >> second >> third >> fourth >> fifth >> sixth;
modified 20-Feb-13 18:10pm.
|
|
|
|
|
ok, we understand the pain ...but what have you tried so far Sarah ?
We try not to do people's homework by just giving them an answer - copying and pasting isnt going to help you learn, is it ?
So, Im going to give you the start of the answer ...
cout << setprecision(x) << fourth << endl;
Why dont you type it in, (note, you need to replace the (x) in setprecision with a number - think carefully, or just try multiple output statements), compile and run it ..
Its probably bad form to have the 'using namespace' clause below, but for testing something quick, Im going to close my eyes and just do it the simple way, so, you'll also need
#include <iostream>
#include <iomanip>
using namespace std;
at the top of your program.
try it ...
|
|
|
|
|
Thank you this is what I was asking, just a start because I have litterally never written code in C++ only pseudocode. I am just trying to put together how each line will appear. He provided the entire program we have to fill in our solution. Here, I'll show you...
Exercise 3:
Objectives: using the iomanip library to format screen output.
Complete the provided main() program with statements to accomplish each of the following. In each case you must use the appropriate I/O stream manipulators to produce the appropriate output wherever possible. Refer to the sample output below as a guide for proper output alignment.
Output first first as an integer value, followed by a space, then in its written form.
Output second as a base ten value, followed by a space, then as a hexadecimal value, followed by a space, then as an octal value. Make sure the appropriate base indicator prefix is shown in the output.
Output third.
Output fourth with four digits, with the sign shown at the left, and the value right aligned. The decimal point must also appear.
Output fourth with four significant figures.
Output fifth with seven significant figures. (Must be left-aligned)
Output fifth with three digits to the right of the decimal point.
Output third.
Output fourth with two digits to the right of the decimal point.
Output sixth with no decimal portion showing
Output fourth with eight digits to the right of the decimal point.
Output sixth with six digits.
You must start your coding by using exactly the following program. You may not modify it, except to add the required code between the Solution starts, and Solution ends comments.
#include <iostream>
#include <iomanip>
using namespace std;
int
main()
{
bool first;
int second;
long third;
float fourth;
float fifth;
double sixth;
cout << "Enter bool, int, long, float, float, and double values: ";
cin >> first >> second >> third >> fourth >> fifth >> sixth;
cout << endl;
// ***** Solution starts here ****
// ***** Solution ends here ****
cin.get();
return 0;
}
SAMPLE PROGRAM OUTPUT (assume user inputs values shown in bold):
Enter bool, int, long, float, float, and double values:
1 69 1464878 6443.39 -7.273 -6443.39
1 true
69 0x45 0105
1464878
+ 6443.
6.4434e+03
-7.2729998e+00
-7.273
1464878
6443.39
-6443
6443.39013672
-6443.39
|
|
|
|
|
ok, I suggest you comment each section you're working on, between the
Sarah Trattner wrote: // ***** Solution starts here ****
marks, it'll make it easier ... so it'll look like
cout << something << first << " " << something-else << first << endl;
cout << third << endl;
But you'll see in Part 1, Ive deliberately used 'something' and 'something-else' ... ok, so, you're outputting a boolean value - you need to pick the two flags that work particularly well with booleans, and, there's an obvious hint - one starts with 'bool' .. once you find the flags - they'll be in your notes for sure, put them into the statement .. you'll also see Ive commented out the start for Part 2 - you can comment lines out that you're experimenting with or jotting down ideas, so that if they are wrong, your program will still compile ..
do you follow so far ?
|
|
|
|
|