|
Hi,
I've set it's buddy to my edit control :
m_spinPtSpeed.SetBuddy(GetDlgItem(IDC_SPIN_PTSPEED));
m_spinPtSpeed.SetRange(1,14)
and I want to increase or decrease the value in the edit box,and when type a value into edit box,spin control can increase or decrease the current value in the editbox.So I handle the message UDN_DELTAPOS ,but the editbox's value did't change!
void CCam1Set::OnDeltaposSpinPtspeed(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
//Get value from the edit control
m_nPtSpeed=(int)GetDlgItemInt(IDC_SPIN_PTSPEED);
//adjust value
m_nPtSpeed=m_nPtSpeed-pNMUpDown->iDelta;
//display new value
SetDlgItemInt(IDC_SPIN_PTSPEED,(UINT)m_nPtSpeed,T
RUE);
*pResult = 0;
}
Can you help me solved my another problem
|
|
|
|
|
Is IDC_SPIN_PTSPEED mapped to a CEdit control or a CSpinButtonCtrl control? Its name implies a CSpinButtonCtrl control yet its use implies a CEdit control.
|
|
|
|
|
Hi DavidCrow,
Thanks for your directions,I made a obvious mistake,I had test it ok!thanks!
Can you help me to solve my another problem? If Can ,I will E-mail my demo project for demonstrate problem to you?
|
|
|
|
|
Just post the relevant code here for all to see. The more eyes, the better! Make sure you include what problem you are seeing, any error messages, what you've done so far to isolate the problem, etc.
|
|
|
|
|
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
|
|
|
|