|
Hi CPians!
I am currently trying to write an app that emulates the mousewheel functionnality. A third part software we often use (a kind of text editor) does not seem to handle mouse wheel messages, so i had the idea to set a hook on mouse messages, to identify the top window, and to send a message to that window.
The problem is, the top window does not respond to my PostMessage or SendMessage . If I use "direct" MFC functions (ShowWindow,ScrollWindow ), it works fine, but not when using messages. And the vertical scroll functionnality is only available using a message :
pWndChild->PostMessage(WM_VSCROLL,SB_LINEUP); has no effect at all.
I've also tried to send WM_KEYUP/KEYDOWN messages (trying to make the app react "as if" the user had hit several times the up or down arrow, or pgup/pgdn), but no way.
My pWndChild which is a CWnd* is alright, because it works fine with functions like ShowWindow ,GetWindowText ...
Any idea ?
~RaGE();
|
|
|
|
|
The question is, does the top window process WM_xSCROLL messages, or is it done by one of its children (a contained view, for example)? To sum up, are you sure you're sending the messages to the good window?
All my life, who am I?
|
|
|
|
|
Rage wrote:
Any idea ?
Try setting the lParam of the message to the window handle of the window's scrollbar control.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
shrunkenpic is an array with the picture data. It is an unsigned char array with values between 0 and 255
I want to display it
why this code doesn't work. I get only a gray surface not the picture I expect. The picture in the memory ist ok if i display it with setpixel it works and looks fine but this method is to slow
I get about 10-15 pics per second from a cam, so the way to save it first to a bitmap file and then display it is to slow.
CBitmap bild;
bild.CreateBitmap(348, 260, 1, 8, shrunkenPic);
bild.SetBitmapBits(348*260,shrunkenPic);
CDC imageDC;
imageDC.CreateCompatibleDC(pDC);
imageDC.SelectObject( &bild);
pDC->BitBlt(0, 0, 348, 260, &imageDC, 0, 0, SRCCOPY);
imageDC.DeleteDC();
Any Ideas?
Heiko
|
|
|
|
|
Have you tried something like this?
CBitmap bild;<br />
bild.CreateBitmap(348, 260, 1, 8, shrunkenPic);<br />
bild.SetBitmapBits(348*260,shrunkenPic);<br />
<br />
CImageList imageList;<br />
imageList.Create(348, 260, ILC_COLOR24, 0, 1);<br />
imageList.Add(&bild, (CBitmap *) NULL);<br />
imageList.Draw(pDC, 0, CPoint(0, 0), ILD_NORMAL);
All my life, who am I?
|
|
|
|
|
unfortunately, the displayed picture is only black
this doesn't work
Ohter Ideas?
I think the failure must be in the CBitmap. Its creation must be buggy.
|
|
|
|
|
I never used CBitmap::SetBitmapBits, so I can't tell if it works well.
what is your object pDC? A ClientDC?
All my life, who am I?
|
|
|
|
|
pDC is the DC of the control(picture-control) into which i want to paint the bitmap
CDC *pDC = GetDlgItem(IDC...)->GetDC();
|
|
|
|
|
I've never use a picture control this way, and I don't know if it is possible to use directly its DC.
Why not using directly a CWnd and catch the WM_PAINT message? At least you would have a total control of the drawing.
All my life, who am I?
|
|
|
|
|
The Problem is the creation of the cbitmap. If i load it from a file or from a ressource it works the way i like.
Only to create its own cbitmap makes some trouble
|
|
|
|
|
Have you tried to work with a BITMAP structure (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_2h6a.asp)? Once all the fields of the structure set, it's easy to convert it to a CBitmap object.
All my life, who am I?
|
|
|
|
|
I currently have an array filled with int values from 0 to 255, but I need to pass this array into a function that takes double. So my problem is I can't convert the int array of values 0 to 255 to a double array...I've tried cast and even just defining that original int array as a double. all I get is my data being turned to some very large negative values.
Is there a way ard this?
Thnx.
|
|
|
|
|
I think you've castet only the pointer.
You will have to make an new array and then cast every value into the new array.
|
|
|
|
|
You'd like to think it to be as simple as:
int nNumbers[5] = {2, 8, 8, 7, 0};<br />
double dNumbers[5];<br />
memcpy(dNumbers, nNumbers, sizeof(nNumbers));
but since a double is not the same size as an int, this isn't going to work.
It'll take a few more lines of code, but you'll need something like:
for (int x = 0; x < 5; x++)
dNumbers[x] = nNumbers[x]; before calling the function.
|
|
|
|
|
Does anyone know how to write a service to forbid execution of a specified application (ie maybe ???)
Thanks for all.
Lionel
|
|
|
|
|
I don't think it is possible to forbid an application from executing. Allthough I know that in XP there is something ( group policies I think ) where you can block certain applications.
What you could do if you want to block an application is use a system-wide hook in a dll and check when a window is created. From that window you can easily get the executable's name and end the process if you don't want it to run...
Don't think you are, know you are...
|
|
|
|
|
If the application in question is on an NT-type box, you can alter the security/permissions of it so that only certain users/groups can execute it. When your service tries to execute the application, it will error out accordingly.
|
|
|
|
|
to hanlde all different formats from around the world
|
|
|
|
|
I'm not sure to have understood your request well. If you want to display a date in a localized format, have a look to the class COleDateTime, and the member function COleDateTime::Format.
All my life, who am I?
|
|
|
|
|
i want to show my window which is derived from CWnd in the button clicked event .the following is my code
void CTmp_dlgDlg::OnButton1()
{
RECT rect;
CString str;
GetWindowRect(&rect);
CMyWnd *mywnd = new CMyWnd;
str = AfxRegisterWndClass( 0);
int ret=myWnd->Create (str,"text",WS_VISIBLE|WS_CHILD,rect,this,1234);
mywnd->ShowWindow (SW_SHOW);
}
CMyWnd::CWnd
but i can't show the window,why?
gucy
|
|
|
|
|
Try
void CTmp_dlgDlg::OnButton1()
{
RECT rect;
CString str;
GetWindowRect(&rect);
ScreenToClient(&rect);
CMyWnd *mywnd = new CMyWnd;
str = AfxRegisterWndClass( 0);
int ret=myWnd->Create (str,"text",WS_VISIBLE|WS_CHILD,rect,this,1234);
mywnd->ShowWindow (SW_SHOW);
}
rechi
|
|
|
|
|
it do not work at all
gucy
|
|
|
|
|
How CMyWnd looks like? I made a test wich draws a line on WM_PAINT and worked just fine.
rechi
|
|
|
|
|
the app the a dialog based app.
i clicked the button on the dialog. nothing changed.
i think it would have pop out a window.
Can i mail the source to you?
gucy
|
|
|
|
|
gucy wrote:
Can i mail the source to you?
Give it to me!
rechi
|
|
|
|