|
In my code, If the user uses File|Exit, I check to see if a file has been saved and offer the user options. How can I trap the user clicking the Close program box in the upper right hand corner, or using alt-F4 to close the program in order to prompt them to save or forget the program changes they have made.
Thanks in advance.
Steve S
|
|
|
|
|
The window should recieve the WM_DESTROY message. I'm unsure however if that would help you with your problem
Sprudling
|
|
|
|
|
|
How can I do an ownerdrawn window and which class should i use.......
|
|
|
|
|
Derive from CWnd and override OnPaint().
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
Does anybody have any idea why this program leaks ? It's a problem with STL or what ? I'm using VC++ 6.0, SP 5, W2K
#include <fstream>
#include <crtdbg.h>
using namespace std;
void test()
{
fstream fs("dbg.txt", ios::out);
fs.close();
}
void main(void)
{
test();
_CrtDumpMemoryLeaks();
}
|
|
|
|
|
It doesn't leak. The problem (if you can call it that) is that _CrtDumpMemoryLeaks is being called before global object destruction, thus it thinks there is a leak when the object is really destroyed afterwards.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
So STL has global objects ? (besides cin,cout and cerr ). Because I don't have any global objects ( that's my concern - the fstream object is created on the stack , so it's destroyed before I call _CrtDumpMemoryLeaks) .
If it has, do you have any idea, are these objects thread safe ? And can you name some ?
|
|
|
|
|
I am a fairly new user to MS Visual C++ 6 and I have a couple of questions.
Is there a way that I can monitor the value in say an edit box in another Windows program and get the new value to do some kind of computation on it??
Another question is how would I go about sending inputs and outputs through an I/O board?? Is it possible as well to count the ticks of an encoder?
or would getting a value from a decoder on an I/O board be a better way, and how would I do this??
Any sample codes or help with codes would be GREATLY appreciated, but
any feedback will be helpful.
thanks
|
|
|
|
|
I'm sure the standard answer is "it all depends."
We interface in Win98 with hardware boards using "_inp" (in port) and "_outp" (out port) instructions, knowing what the port number is for the board. Those are directly callable from C++. Depending on the OS, you may not be able to get access at that level of hardware. WinNT "helps" us, by isolating us from that level of control with hardware.
Other devices may be "memory mapped" devices, where their control registers exist at an address, and then driver functions can be called to perform some action. That all depends on the board, of course. The I/O buffers may be memory mapped too, so getting data is a matter of accessing elements from an array, using a pointer initialized to the address of the I/O area.
Remember, too, that Windows is not "real time," and depending on your application, may not be suitable for really fast data I/O. Slow stuff is alright, but that will depend on your application.
Dave
|
|
|
|
|
I need a really simple data grid to put on a dialog to enter a 25x25 grid of integers, I have looked at CDataGrid, but I can't seem to enter data into it. I have also looked at Chris Maunder's MFC Grid control 2.23 but this seems a bit too complicated for my needs, and does far more than I require.
Any ideas
cheers andy
Andy
|
|
|
|
|
VC comes with several simple grids, none of which accept input. I believe this is by design, because the MSDN gives instructions on how to make them accept input ( basically create an edit control, put it over the grid, get the input, put it in the grid ), so I think the idea is that the input is only there if you decide to add it.
I dunno, but would a CListCtrl allow 25 columns ? It might be a much easier solution, and I don't see why it shouldn't, I just have never gone beyond 6 or so myself.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
A (system wide) keyboard hook from another application crashes our Win16 application
Our app is built with VC++ 1.52, remember that?
Occurs (mostly) on Windows98 & ~SE.
Anyone seen problems like this before?
Even more importantly: Any ideas on how to avoid the crash from OUR app?
Or maybe narrow it down somewhat, to what actions in the hooking DLL could be causing this?
Thanks for any response/pointers/leads/etc.
Jorik.
|
|
|
|
|
I've downloaded a font and installed it on my machine.
I can use it easally in my MFC prj's by using CFont::CreateFont().
But... how can I assure that when I run my task on other machine the font
will be found and created properly, or In other words,
how can I add it to the resources and load it from there?
--BlackSimth--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
I'm not so sure about if you can use a font "file" if it not is installed but if we say yes: Just add it like you add a simple bitmap as a resource. Right click the map in the tree view in VC++ and click "Import...". Then youst find the font and after that you'll be saked to write a resource type name: eg. Font. DONE!
But as I said before! I don't know if you can use uninstalled fonts...
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Ok, I give up. I am going to have to give in and ask for some help.
I am trying to change the colours of a bitmap (make it grayscale). I have got it working for 16, 24, and 32 bit bitmaps, but I am lost as to how to do this for 4 and 8 bit bitmaps
The HBITMAP passed into my function could be a DIB or a DDB
HBITMAP #####::GrayScale(CDC *pDC, HBITMAP hBitmap)
{
BITMAP bmp;
::GetObject(hBitmap, sizeof(BITMAP), &bmp);
if (bmp.bmBitsPixel < 16)
{
}
else
{
HBITMAP hDib = (HBITMAP)::CopyImage(hBitmap, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG | LR_CREATEDIBSECTION);
DIBSECTION DibSection;
::GetObject(hDib, sizeof(DIBSECTION), &DibSection);
int Size = DibSection.dsBmih.biWidth * DibSection.dsBmih.biHeight;
BITMAPINFO bmi;
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biHeight = bm.bmHeight;
bmi.bmiHeader.biWidth = bm.bmWidth;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = bm.bmBitsPixel;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = ((bm.bmWidth * bm.bmBitsPixel + 31) & (~31)) / 8 * bm.bmHeight;
bmi.bmiHeader.biXPelsPerMeter = 0;
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
BYTE *pBits;
::GetDIBits(pDC->m_hDC, hDib, 0, bm.bmHeight, pBits, &bmi, DIB_RGB_COLORS);
...
...
::SetDIBits(pDC->m_hDC, hDib, 0, bm.bmHeight, pBits, &bmi, DIB_RGB_COLORS);
return hDib;
}
}
It is my understanding that in 4 and 8 bit bitmaps, the bits returned by GetDIBits() are actually pointers into a colour table, and to change the image to grayscale I have to change the colour table. How do I get access to the colour table
I have tried
::GetDIBColorTable(memDC.m_hDC, 0, 1<<bmp.bmBitsPixel, rgbquad); For a 256 colour bitmap, ::GetDIBColorTable() returns 256, but the rgbquad array is full of garbage (every entry is 0xcc in debug mode). I have read Zafir Anjum's Drawing an image in grayscale but I could not get that to work the way i wanted either. I have tried several other things but nothing seems to work
I am probably missing something obvious and I hope some one can point out to me what it is.
---
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
The GetDIBColorTable code you gave works. Are you using CopyImage with LR_CREATEDIBSECTION as you in the code for non palettized bitmaps?
Here's my test code (in C). It was successful in retrieving the palette of a 4 bit and 8 bit bitmap made with MS Paint.
HBITMAP hbm = NULL, holdbm = NULL;
HDC hdc = NULL;
RGBQUAD pal[256];
BOOL MainFrm_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct)
{
hbm = (HBITMAP)LoadImage(NULL, TEXT("test.bmp"), IMAGE_BITMAP, LR_DEFAULTSIZE, LR_DEFAULTSIZE, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
if(hbm)
{
BITMAP info;
GetObject(hbm, sizeof(BITMAP), &info);
hdc = CreateCompatibleDC(NULL);
if(hdc)
{
holdbm = SelectBitmap(hdc, hbm);
GetDIBColorTable(hdc, 0, 1<<info.bmBitsPixel, pal);
}
}
return TRUE;
}
|
|
|
|
|
I'm sure this may be a usual question here but I want my app to check my POP3 account!? HOW, is there some greit classes here somewhere??
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
|
Hi,
I used this class some time ago. It worked fine at first. But after some time I got a strange error. I realized that the program was unable to create the socket. Then using GetLastError method, I found the error:
"Either the application has not called WSAStartup, or WSAStartup failed."
Then I called WSAStartup method in the constructor and WSACleanUp in the destructor. I am not sure if this is the correct way or not. Are there other ways to do it?
Kind regards
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
|
|
|
|
|
see :-
http://www.codeproject.com/internet/cpop3conn.asp
http://www.codeproject.com/internet/popwatch.asp
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Hi,
I have three problems.Please answer.
Problem 1:(BIGGEST)
-------------------
I make a call like this
OnDraw(CDC *pDC)
{
//.....
MyDrawFunction(pDC);
//....
}
Should I release the CDC * in my function because
1)When I scroll rapidly,the figures drawn by my
function looses color;
2)When I use Alt-Tab and return to my program,
the figures will be displaced.
But these things donot happen to the figures drawn by the
OnDraw function.What is the problem?
Problem 2:
---------
When I create DCs inside my function like
CDC *MyDC = GetDC(); or
CClientDC dc(this) etc
and draw with it,I find problem while scrolling.The figures get smudged.
How to avoid this?
Problem 3:
---------
The exact same thing an in Problem 2 happens when each row in a
list control uses a different color.The colors get mixed while
scrolling.
Thanx
|
|
|
|
|
Can you post your function please!
Then I perhaps can help ya!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
I'm stuck with the following problem. From one application, given the handle to the parent window of another app and the controlIDs of a control (textBox, button, etc) in the app, I need to get the handle of the control in run time.
GetDlgItem() can be used to get the handles of a control in a Dialog based window, But it returns me wrong handle values when I tried with Windows explorer - a SDI based app. Could somebody please point me the approach to get the handles of the controls in a complex window full of combo box, buttons, menus and tree views?
Thanks for any help,
Wally
|
|
|
|
|
Well, you see it's impossible untill you find a SDK of it (like WinAmp) where the developers tell you you the ID of all buttons, list-boxes etc..... therefor you can reach the controls! You need the ID for alla controls and you can't get them in another app just like that!
But now when you read this messeage, try find an answer somewhere else! I can be wrong!!
But whit my research with the problem I havn't found anything that can do what I want!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|