|
I don't know exactly you use which .NET application. I show you close a program completly on Visual C++ .NET:
You add below code in your button::onClick(..) methot (exit button);
Application::Exit();
|
|
|
|
|
Hi,
I am using Visual C++ for my application but i am not very sure of the code u say.
i have a function name:
void CProjectGrid::OnExit()
{
OnExit();
}
i tried on the above and it works fine with the pc at home.. but when i run this program in school, it prompt mi for some error. so for the coding that you showed me. Where should i place it in the function above?
Thanks for your help
|
|
|
|
|
Hi,
Thanks for the help given.. I have solved my problems.
thanks a million
dreamerzz
|
|
|
|
|
Hi all,
i want to store my window as a bitmap file and read it.(Without using MFC classes)
Can somebody help me!!!!!!!!!!!
|
|
|
|
|
do not waste your time. exist more programs to saving screen in various picture format. i use ctrl+insert buttons to store screen into clipboard and paste that into Micrsoft paint where i arrange what i want but only for making documentation with screenshots (its free tool).
regards,
|
|
|
|
|
Pls its a kind of assignment and i have to do it.So can u help me in reading a bitmapm file
|
|
|
|
|
Ok. I think that you are can use API functions. Here is my approach with small code:
HWND DeskHwnd; // desktop window
HDC hdc, hdcMem; // device
HBITMAP hBitmap; // bitmap handler
unsigned char *bits; // data bits
DeskHwnd = GetDesktopWindow(); // get windows handler
hdc = GetDC(DeskHwnd); // get dc
hdcMem = CreateCompatibleDC(hdc); // mem dc
hBitmap = CreateCompatibleBitmap(hdcMem, YOURwidth, YOURheight); // bitmap handler with your size
BITMAPINFO lstr_Info; // bitmap info
BITMAPFILEHEADER lstr_Header; // bitmap info header
// fill bitmap info header
memset(&lstr_Info, 0, sizeof(BITMAPINFO));
lstr_Info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
lstr_Info.bmiHeader.biWidth = fwidth;
lstr_Info.bmiHeader.biHeight = fheight;
lstr_Info.bmiHeader.biPlanes = 1;
lstr_Info.bmiHeader.biBitCount = 24;
lstr_Info.bmiHeader.biCompression = BI_RGB;
lstr_Info.bmiHeader.biSizeImage = 0;
lstr_Info.bmiHeader.biXPelsPerMeter = 0;
lstr_Info.bmiHeader.biYPelsPerMeter = 0;
lstr_Info.bmiHeader.biClrUsed = 0;
lstr_Info.bmiHeader.biClrImportant = 0;
// use this function and check if is greater than 0
GetDIBits(hdcMem, hBitmap, YOURstartPos, YOURheight, 0, &lstr_Info, 0);
// you got information about bitmap header
if ((bits = (unsigned char *)malloc(lstr_Info.bmiHeader.biSizeImage)) == NULL)
EXIT;
// now you can read bits
GetDIBits(hdcMem, hBitmap, 0, YOURheight, (VOID *)bits, &lstr_Info, 0);
OK, you have almoust all information about the bitmap to save it on your disk. This code is only pseudo code.
Here are some usefull functions for saving this bitmap into clipboard:
OpenClipboard(DeskHwnd);
EmptyClipboard();
SetClipboardData(CF_BITMAP/*2*/, hBitmap);
CloseClipboard();
Best Regards,
|
|
|
|
|
|
Do a thurough search of MSDN, there was and still may be a sample program (dibview or some thing) that did what you are looking for (in C). If you are willing to do a bit of reverse enginering, then take a look at some of the articles at codeproject. Since MFC are just wrapers for the SDK (written in C), they can (for the most part) be reduced to C. Otherwise you need to look at how a bitmap file is layed out and go from there. One other place you can look for code is "sourceforge".
Every thing you need to know about bitmaps (.bmp) is actualy in the MSDN library.
P.S. Do not for get about the function LoadImage(), which was new when Win95 came out.
INTP
|
|
|
|
|
I am getting this assertion when i start my application
File: dbgheap.c
Expression : _CrtIsValidHeapPointer(pUserData)
Compiler causes assertion when i am deleting an array, array is being created and deleted in
right way the strange thing is that i am getting this assertion not every time i run my programme
required help in this regard
|
|
|
|
|
are you doing any allocation at the start of the program?
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
My project contains a process which should save a Bitmap with 24 bit colordepth.
First we developed this program for 32 bit and then we wanted to change the program into a 24 bit version
That seems to be kind of difficult.
As far as I know there are 2 changes needed:
- the bitmaparray (array which contains the color values) is the size of the image times 3 (It was times 4 at 32 bit)
- In the bitmap header there is one bitmap depth variable
--> set to 24 bit
well, if I change these 2 things the result varies
Once the bitmap contains a totally distorted picture, another time the pixel lines are alternatingly red, green and blue (value is 255 so these colors are fully set 1111 1111)
If I draw this bitmap in MS Paint or some other program I'll get the same data as it is stored with my C++ program
My program's bitmap however can't be displayed correctly
So has anybody experienced that problem or has anybody a solution for it?
Would be nice if you reply
|
|
|
|
|
well, another crazy thing is that sometimes the picture is displayed correctly
sometimes distorted
|
|
|
|
|
When an image is distorted then the information associated with is wrong! It appears that someone wrote the code regarding bitmaps based on the requirment that they would be 32 bit. The simpilist solution I can think of is to use my class CDibData to read and store your bitmaps or one of the other classes presented at codeproject. Simply changing the depth (BitCount) will not work!
What you seem to be doing is what is call "pock and hope".
INTP
|
|
|
|
|
I have a question concerning the use of a function defined in a Dll file.
I don't know precisely how to call a function defined in a Dll file.
I follow what MSDN specified but it doesn't work for the functions which take arguments. Here is the syntax I use to call the function "USB_WriteFile" defined in my Dll "XtlUsb.dll":
typedef BOOL (CALLBACK* USB_WriteFile)(PVOID,DWORD,LPDWORD,ULONG);
HINSTANCE hDLL;
hDLL = LoadLibrary("XtlUsb.dll");
USB_WriteFile pUSB_WriteFile;
PVOID lpBuffer = 0;
DWORD nNumberOfBytesToWrite = 0;
LPDWORD lpNumberOfBytesWritten = 0;
ULONG Timeout = Timeout;
if (hDLL != NULL)
{
pUSB_WriteFile = (USB_WriteFile)GetProcAddress(hDLL,"USB_WriteFile");
if (!pUSB_WriteFile)
{
FreeLibrary(hDLL);
return FALSE;
}
else
{
BOOL BResult = TRUE;
BResult = pUSB_WriteFile(lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten,Timeout);
}
}
I have a fatal error coming from Visual C++ when arriving at the line "BResult = pUSB_WriteFile(lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten,Timeout);"
Do you have any explanations?
Thank's for advance.
|
|
|
|
|
If that's really your code, then you're passing in NULL for the buffer. This may or may not cause you a problem
Steve S
|
|
|
|
|
That doesn't come from that. For example, I use another function which is defined in my Dll. Here is the Code:
typedef BOOL (CALLBACK* USB_ReadFile)(PVOID,DWORD,LPDWORD,ULONG);
USB_ReadFile pUSB_ReadFile;
char chBuffer[66000];
PVOID *lpBuffer = 0;
DWORD nNumberOfBytesToRead = 65536;
LPDWORD lpNumberOfBytesRead = 0;
ULONG Timeout = 5000;
hDLL = LoadLibrary("XtlUsb.dll");
if (hDLL != NULL)
{
pUSB_ReadFile = (USB_ReadFile)GetProcAddress(hDLL,"USB_ReadFile");
if (!pUSB_ReadFile)
{
FreeLibrary(hDLL);
}
else
{
BOOL BResult = TRUE;
BResult = pUSB_ReadFile(chBuffer,nNumberOfBytesToRead,lpNumberOfBytesRead,Timeout);
}
}
and here is the help given in MSDN:
typedef UINT (CALLBACK* LPFNDLLFUNC1)(DWORD,UINT);
.
.
.
HINSTANCE hDLL; // Handle to DLL
LPFNDLLFUNC1 lpfnDllFunc1; // Function pointer
DWORD dwParam1;
UINT uParam2, uReturnVal;
hDLL = LoadLibrary("MyDLL");
if (hDLL != NULL)
{
lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL,
"DLLFunc1");
if (!lpfnDllFunc1)
{
// handle the error
FreeLibrary(hDLL);
return SOME_ERROR_CODE;
}
else
{
// call the function
uReturnVal = lpfnDllFunc1(dwParam1, uParam2);
}
}
The fatal error I have comes from when I call the function with its pointer.
|
|
|
|
|
If you're getting a fatal error (exception, I guess) you could try stepping into the function call with the debugger, and then setting a stop on all exceptions, particularly C0000005 (access violation), and C++ exception.
That might help you work out what's happening.
At a guess, I'd say you were using a USB library to perform I/O to some device. Does your process need particular privileges to do this, or does the device driver (HIDSYS?) take care of it all for you.
Steve S
|
|
|
|
|
I have a question concerning the use of a function defined in a Dll file.
I don't know precisely how to call a function defined in a Dll file.
I follow what MSDN specified but it doesn't work for the functions which take arguments. Here is the syntax I use to call the function "USB_WriteFile" defined in my Dll "XtlUsb.dll":
typedef BOOL (CALLBACK* USB_WriteFile)(PVOID,DWORD,LPDWORD,ULONG);
HINSTANCE hDLL;
hDLL = LoadLibrary("XtlUsb.dll");
USB_WriteFile pUSB_WriteFile;
PVOID lpBuffer = 0;
DWORD nNumberOfBytesToWrite = 0;
LPDWORD lpNumberOfBytesWritten = 0;
ULONG Timeout = Timeout;
if (hDLL != NULL)
{
pUSB_WriteFile = (USB_WriteFile)GetProcAddress(hDLL,"USB_WriteFile");
if (!pUSB_WriteFile)
{
FreeLibrary(hDLL);
return FALSE;
}
else
{
BOOL BResult = TRUE;
BResult = pUSB_WriteFile(lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten,Timeout);
}
}
I have a fatal error coming from Visual C++ when arriving at the line "BResult = pUSB_WriteFile(lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten,Timeout);"
Do you have any explanations?
Thank's for advance.
|
|
|
|
|
could this Jeab. wrote:
I have a fatal error be a little more precise?
Don't try it, just do it!
|
|
|
|
|
Fatal error is now OK. The function must be defined like this:
typedef BOOL (__cdecl *USB_ReadFile) (PVOID,DWORD,LPDWORD,ULONG);
PVOID lpBuffer;
DWORD nNumberOfBytesToRead = 65536;
LPDWORD lpNumberOfBytesRead = 0;
ULONG Timeout = 5000;
USB_ReadFile pUSB_ReadFile;
hDll = LoadLibrary("XtlUsb.dll");
if (hDll != NULL)
{
pUSB_ReadFile = (USB_ReadFile)GetProcAddress(hDll,"USB_ReadFile");
if (!pUSB_ReadFile)
{
FreeLibrary(hDll);
return FALSE;
}
else
{
BOOL BResult = TRUE;
BResult = pUSB_ReadFile(lpBuffer,nNumberOfBytesToRead,lpNumberOfBytesRead,Timeout);
}
}
|
|
|
|
|
below ,it is a part of program.
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
VERIFY(m_editCopy.AutoLoad(IDC_button, this));
TRACE("HELLO");
return TRUE;
}
i insert two bitmaps ,at the same time ,i insert a button whose id is "IDC_BUTTON" and name "copy" .the two bitmap's id are "COPYU" and "COPYD".
I want to connect the copy button withe the two bitmaps by the function of "AutoLoad()",but when i run it,nothing error ,but why can not i get the
expected result?
|
|
|
|
|
I try to find where is error and make small test program like your but it is working well. You must check your code and I do not know did you write resource simbol IDC_BUTTON or "IDC_BUTTON". Second is wrong in your case.
Regards,
|
|
|
|
|
I'm looking for a hash table that maps strings to strings. I want to use this in a hooking procedure. The classical mfc classes don't work because pointers are a big nono for global hooking (dll mapped at different addresses for different processes). I tried and it sometimes works but most of the time not.
Basically I need a hooking class that uses static allocated tables. It should also know to manage memory itself (no malloc or free allowed) internally. Anyone know of such a class before I reinvent the wheel ?
|
|
|
|
|
Hi...
It's my first time using vectors and I'm having problem using the 'begin' method. I did as follows...
vector ** a = new vector *[size];
...
vector<int>::iterator iter = a[u][v].begin();
a[u][v].insert(iter,lab);
...
I get unhandled exception error upon reading the iterator statement.
Pls help me allocate a value at the beginning of the 2d array...
Thank you.
Rgrds.
|
|
|
|