|
I had post my another problem's code in last thread(there is link),I want to make the problem clear,so I made a demo project,but it's bigger than permit post in the forum .Who can offer the FTP position so can I place the demo project to be download? Or I will send to him directly
|
|
|
|
|
Hello, I'm new to VC++ and have problems displaying a DIB in a formview.
To get the device context of my formview and display in it my DIB, I use :
CPaintDC dc(this);
CDC* pDC = &dc;
StretchDIBits(
pDC->GetSafeHdc(), // dc
300, // x dest
300, // y dest
int(proc->IMAGE_WIDTH), // x dest dims
int(proc->IMAGE_HEIGHT), // y dest dims
0, // src x
0, // src y
int(proc->IMAGE_WIDTH), // src dims
int(proc->IMAGE_HEIGHT), // src dims
proc->img->imageData, // array of DIB bits
proc->bmi, // bitmap information
DIB_RGB_COLORS, // RGB or palette indexes
SRCCOPY // raster operation code
);
Everything compiles fine, but when I launch my application, the picture doesn't show.
Could someone tell me if I did something wrong or forgot to add something to make the picture appear (I tried to do the same with a dialog box and used the onPaint() method that was automatically called when I forced to redraw my window, but I don't know how to do that with a formview).
Any help would be much needed.
Thank you
|
|
|
|
|
1. where are you doing the StretchDIBBits? (OnDraw?)
2. what is the return value from Stretch*?
3. try calling GetLastError just after Stretch*
4. is the DIB valid?
-c
|
|
|
|
|
1. Let me first explain more precisely what I'm trying to do : I grab images from a video file and I would like each image to be displayed with StretchDIBBits when I press on a "play" button. So I put my StretchDIBBits function in the function called when I pressed the play button(OnPlay). Tis is probably where I'm wrong because I don't do it on the OnDraw method.
What I tried was to call the OnDraw method in the OnPlay function. Everything compiles but I get an execution error, so I might not be able to do that.
2-3. my Stretch method doesn't give an error, and my DIB is valid.
I think that my only problem is to make my program actually display the picture.
thanks for your help
|
|
|
|
|
sandrineV wrote:
What I tried was to call the OnDraw method in the OnPlay function. Everything compiles but I get an execution error, so I might not be able to do that.
yes, that's true. OnDraw will be called when Windows sends a message to tell your app that it needs to be redrawn. if you want to tell Windows to tell your app to readraw itself, you can use CWnd::Invalidate to invalidate a window. so, at each frame:
1. load the DIB
2. call Invalidate on the CView
in the CView's OnDraw, draw the DIB
-c
|
|
|
|
|
Thanks for your answer,
When I do what you said, I still have an execution problem at the end of my StretchDIBits. Could this be because a formview is not a valid device context ? I ask this because I was able to draw the picture using the same function (StretchDIBits) in a dialog based application without problems...
Thanks
Sandrine
|
|
|
|
|
you should be able to draw on a CFormVIew the same way you would any other view.
when you say 'execution error', do you mean the application asserts, or gives an access violation?
-c
|
|
|
|
|
it gives an access violation...
Sandrine
|
|
|
|
|
make sure the DIB is valid before you draw it. OnDraw will probably be called by the OS long before you get a chance to load the DIB.
-c
|
|
|
|
|
I need to treat NM_RCLICK of a non-empty list control m_list1 placed a form view, using MFC. Here's the code:
void CSimpleView::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
int index;
UINT uFlags;
CPoint p;
GetCursorPos(&p);
ScreenToClient(&p);
if ((index = m_list1.HitTest(p, &uFlags)) > -1)
TRACE(_T("OK %d\n"), index);
*pResult = 0;
} It fails every time returning -1 on index
Do you know what's wrong here?
rechi
|
|
|
|
|
m_list1.ScreenToClient(&p); ?
~RaGE();
|
|
|
|
|
Rage wrote:
m_list1.ScreenToClient(&p); ?
Yes! Thank you!
rechi
|
|
|
|
|
I want to know how to open a file using notepad in VC++. I do not want to use
system("notepad.exe filename").
Thank you
|
|
|
|
|
CreateProcess() ?
~RaGE();
|
|
|
|
|
If the file is already associated with Notepad, just use ShellExecute().
|
|
|
|
|
Hello, I am somewhat new to C programming for Windows, but I am an experienced VB programmer. I have recently written a DLL in VC++ for use in VB with API-style calling conventions (which works great), but now I am trying to write a DLL to create owner drawn menus (I already completed that part), but now I want to be able to use it in a class because it only works for one menu item as it is. The trouble is I can't figure out how to export classes to where they work in VB. My research indicates that I should use COM. I tried that, and eventually I got the class to show up in VB's Object browser, but when I try to instantiate it, I get an error 429: "ActiveX component can't create object". Does anybody know what I could do to correct this?
Thanks in advance.
PS
I know there are pre-made programs to create the menus, but I prefer to do it myself, I don't like to use someone else's code if I don't have to. This being an exception of course.
|
|
|
|
|
Is there a simple way to set the background color of a CView ?
|
|
|
|
|
Override CYourView::OnEraseBkgnd(CDC *pDC) and fill the client area with desired color/pattern there. Return TRUE - do not call the base implementation.
There are many ways to reach this, some other could be better for your specific needs (unless you derive from CView only to draw the background ).
Regards,
BB
|
|
|
|
|
Hi all,
does anyone know hot to be notified if a .exe file start running? I both need it for regular applications and services, too, but I think the solution could be the same. Basically I would need of a signaled event when the monitored .exe is start running for app. I would also need a signaled event when some changes happen in the services controlled by the Service Control Manager.
Thanx in advance.
Regards,
Andrea
|
|
|
|
|
There are a lot of methods to do this...
here two of them (possibly not the best of them, but the ones I know )
1.
You can use findwindow in time intervals in order to know if your app is there, this is an easy trick, but it can be a problem if your app hungs.
2.
your app can lock a dummy file and the others can monitor that file state, if it is locked your app is running...
Hope this helps.
|
|
|
|
|
Hi Joan,
unfortunately these solutions have a counterpart: they need CPU time for testing!
I need something more efficient...
Regards,
Andrea
|
|
|
|
|
yes, of course those solutions need CPU, but how do you want to be sure that the app is going on without looking for it often?
Imagine that you send a message from your app to the "controller" (I'll call controller to the application that needs to know if your app is active) when your app starts, and another when your app stops...
If you can ensure that your app won't hung and that the controller is started before the app, this could be a good solution, think about a button (or something similar in your controller in order to kill the flag (only in case that your app hungs)).
Remember not to use FindWindow (if your app can hung, this could make the controller hung also).
Think about:
what could happen if your controller was not started before the app?
For this reason I thought on the file locking method... (that sacrifices some CPU making the controller looking after that, but gives you almost all the control needed.
I've used that in order to make two controlling services to know about if my app was running, if my app, or one of the services was stopped the computer immediately stopped... (this was done in a console computer environment (a computer programmed to move a machine)).
If you don't need to know about the state of your app. you can use the sending of messages, cheap and easy.
Think about a messages protocol that allow the two apps to communicate...
hope this helps...
|
|
|
|
|
I have posted this question before a long time ago and nobody gave me an answer, but I kind of came up with a solution. However, the problem surfaced again. Here it goes.
I am using MSHFlexGrid to create tables and the user is allowed to delete rows from the table. The function that I use for that is RemoveItem. If the user wants to add a new row I call AddItem. However, after a call to RemoveItem, the next call to AddItem will not show the row on the control. The row is there (after AddItem) because when I write data on its cells, I get no errors. Another call to AddItem and voila, I have an empty new row on the table. This doesn't seem to work in the all the cases. Has anyone ever dealt with this problem before?
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Hi, i new to visual c++, and was required to make a project that can...
1) capture the navigation when user surf the net (maybe into a database?)
2) then i can view what web site has being navigate. (sounded like a history folder).
I surf a lot of web site trying to get any info for this but can't find any.
Then i read up that using ChtmlView can work like IE, which may solve my problems, but then i was wondering how can CHtmlView capture the navigation into a database so that i can view it later?
In need of help here. Any ideas?
I'm a newbie to visual c++, simpler terms please.
|
|
|
|
|