|
I created a custom control derived from CWnd. I need to cascade many of these on a CFormView. I am able to create and cascade them but when I click on a portion of the top most control which is over another control, the control underneath receives the mouse input and not the top most one. I tried to disable the previous control but I need to receive WM_ messages for all the cascaded controls.
I also tried this with a standard CButton class and the same problem occured.
Does anyone know how to prevent this behaviour?
Thanks in advance
|
|
|
|
|
We do seem to have amazingly similar problems in spite of the applications being quite different. My application is for subitem editing of a list control, which also uses overlapped windows.
So thank you for mentioning SetWindowPos. There are so many functions like it and the documentation does not make it clear that SetWindowPos would be useful in my situation.
I think that something else I would have tried instead is BeginDeferWindowPos, EndDeferWindowPos and DeferWindowPos. I do not understand exactly what they do and how they work but they might be useful when the z-order of multiple windows needs to be specified. Are they not relevant to you situation?
|
|
|
|
|
Anyone know how to reset the z-order of a window's children to be a specified z-order? Actually, I only need to be able to specify which child to be on top. I am hoping to control which child window gets the mouse click this way. So far setting focus does not work to determine who gtets the mouse click. SetActiveWindow does not affect the z-order, and I think that there is nothing to counter-act it but I will attempt to ensure that that is not a problem.
|
|
|
|
|
To set the Z-Order:
SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
|
|
|
|
|
Thank you. I think it is working. Since I am using MFC, I converted your sample to:
m_pEditWindow->SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
There are still some problems with my program but it is likely that they are separate problems. I think that the z-order part is probably solved.
|
|
|
|
|
Hi all,
i have a problem with a function which writes a DIB to a BMP file. The strange thing is that it works with small pictures but fails with big ones
(it messes up the dimensions...)
The raw bitmap data is saved in a 32 bit format, so i have to convert it to 24 bit first. Here is the code...
BITMAPFILEHEADER bfh;
BITMAPINFOHEADER bih;
unsigned char *data=(unsigned char*)malloc(3*m_nDataBr*m_nDataHo); // for the 24 bit data
unsigned char *p=(unsigned char*)m_pdwData; // this is the 32 bit data
for (int i=0, j=0; i<4*m_nDataBr*m_nDataHo; i++) {
data[j++]=p[i++];
data[j++]=p[i++];
data[j++]=p[i++];
}
// Initialize all structures
memset(&bfh, 0, sizeof(BITMAPFILEHEADER));
memset(&bih, 0, sizeof(BITMAPINFOHEADER));
bih.biSize=sizeof(bih);
bih.biBitCount=24;
bih.biHeight=m_nDataHo;
bih.biWidth=m_nDataBr;
bih.biPlanes=1;
bih.biCompression=BI_RGB;
// Fill in the Bitmap File Header
bfh.bfType=((WORD)('M'<<8)|'B');
// Calculate the size of the bitmap including the palette (which should be empty)
bfh.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+m_nDataHo*m_nDataBr*3;
bfh.bfReserved1=bfh.bfReserved2=0;
// Offset to actual bits is after palette
bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
ASSERT(bfh.bfSize>sizeof(BITMAPFILEHEADER));
// Write the results
fwrite(&bfh, sizeof(BITMAPFILEHEADER), 1, f);
fwrite(&bih, sizeof(BITMAPINFOHEADER), 1, f);
fwrite(data, m_nDataHo*m_nDataBr*3, 1, f);
I really don't know what i am doing wrong here... if anybody could help me i really would be glad.
Chris
|
|
|
|
|
Hi Chris,
What exactly is the problem?
Are you able to open the image in some editor?
|
|
|
|
|
Well, if the image is not very big (lets say 200x200 pixels) then it's no problem at all. If it's bigger you
still can open it in a editor, but with some strange effects:
- it might be stretched
- some parts of the image might be grey, not colored
things like that.
|
|
|
|
|
Now I remember that Windows bitmaps must be 32-bits aligned, that is the length of each row must be a multiple of 4 (padded with zeroes).
So you have to re-code the loop which converts the image from 32 to 24 bits to do the alignment.
I forgot that!
Cheers,
Paolo.
|
|
|
|
|
You may also take a look at WINCAP sample in Knowledge Base art. no. Q97193, which contains the DIB API.
|
|
|
|
|
It works now, it was the 32bit-alignment...
BMP files really are a mess!
|
|
|
|
|
under www.imagemagick.org there is a really good image library for free.
No one should nowadays work so low-level like using those Platform SDK image functions, if he can avoid them.
|
|
|
|
|
I would like to add icons to my menu popup items
I am using SDK.
|
|
|
|
|
Im writing an application that displays an image from a web cam on a CFormView. I derived CCamWnd from CStatic
and override OnPaint to display the image. I wanted to take it to the next step and have it handle a windows
message. For example a doubleckick would switch between zoomed in and normal mode. I cant seem to get
the messages passed through to my class. I can get messages passed through to a class derived from
CEdit without a problem.
What is the difference between these two classes...why do they behave differently.
Any comments or suggestions would be greatly appreciated.
Paul Galla
|
|
|
|
|
A static control will notify you of double-clicks, as long as it has the SS_NOTIFY style set. It will send a STN_DBLCLK notification to the parent window via a WM_COMMAND message.
|
|
|
|
|
Is this possible to do using MFC classes?
Either way, where can I find information about this (preferably with source examples...)?
/XTSea
|
|
|
|
|
I use raw Windows sockets.
How to check whether the other side of the connection is closed?
Thanks
|
|
|
|
|
hi,
i really need help in windows sockets, here is a function i wrote to connect to server:
//----------- Function Implementation --------------------------------
bool ConnectToSocket()
{
if (WSAVERNOTSUPPORTED == WSAStartup(MAKEWORD(2,0),&WSAData))
{
printf("WSAStartup Failed!\r\n");
return FALSE;
}//end if
else
{
printf("WSAStartup Success\r\n");
}//end else
// construct socket
sock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if (sock == INVALID_SOCKET)
{
printf("Failed to construct socket!\r\n");
WSACleanup();
return FALSE;
}//end if
else
{
printf("Socket construction....Success\r\n");
}//end else
// fill in socket address struct and connect to server
sa.sin_family = AF_INET;
sa.sin_port = 23;
sa.sin_addr.S_un.S_addr = inet_addr("147.234.12.233");
int iErr = connect( sock,(SOCKADDR *)&sa,sizeof(sa));
return TRUE;
}
it doesn't seem to work ,i dont know why..... also how do i receive and send data????
please help me i am desperate!
tnx a lot
yaron
|
|
|
|
|
there are some possebilities
the first 1 is that the server is not up
you don't check errors at all
in the winsock.h there are list of errors
you can take the error value
(which is unsigned int)and send
it to acheckerror function
which does switch case over all the possebilities
and then know more specific what is
the problem
any way good luck
Rami Buchnik
|
|
|
|
|
I'm new to VC++
I'm working on a project that I took over from someone else.
It a stats program that reads data from a database and uses OleChart
to output a chart, well anyway when the program starts in debug
I get an Assertion failed message, Message is about strcore.cpp on line
519 and on line 479 what I have been doing is ignoring them and the
program loads fine but when I'm running the program and I click on
any of the combo boxs or radio buttons I get another assertion message
about winocc.cpp line 311. Now I don't expect you all to tell me what is worng
but if anyone else has seen this please respond.
BTW the program does work in debug but crashes in the release version ?
|
|
|
|
|
About the strcore.cpp-assertion: if you click on "retry" the debugger-ide jumps to this assertion.
In your debug window you can now switch through the contexts of the caller function; this way you
can find your source which is responsible for this assertion. Maybe you're trying to access a CString-buffer
which is empty or something like that.
About the winocc.cpp: just do it the same way. Run with F5, wait for the crash and check the caller
functions.
About the debug/release thingy: THIS is something really nasty and you will need a lot of luck to
catch such bugs. Sorry
Chris
|
|
|
|
|
I found the bugs in the release version
and I'm going to try what you said for the debug version.
But most of all thanks for replying.
cmpssp
|
|
|
|
|
Hi
How can I add an message handler for a item I added dynamically in an application's menu. Please help
|
|
|
|
|
Use the ON_COMMAND macro in the message map, like:
ON_COMMAND(IDC_NEW_MENU_ITEM, OnNewMenuItem)
And the function prototype is:
afx_msg void OnNewMenuItem();
|
|
|
|
|
Hi,
I'm writting a FTP Client, using CSocket. And i have problem with the reply format of LIST command.
I tried on some different kinds of FTP server (UNIX, WINDOWS, DOS model), and saw it not the same. Tried to guess the format, but failed.
Who can help me out of this? every suggestion would be appreciated.
Trieu Hai Nguyen
haitrieu@glassegg.com
|
|
|
|