|
|
Hello all...
I am having a problem with the animation control on a dialog. In my
WM_INITDIALOG handler, I have the following code:
<br />
case WM_INITDIALOG:<br />
hAnim = CreateAnimationCtrl(hDlg, IDC_ANIMATE);<br />
Animate_Play(hAnim, 0, -1, -1); <br />
RedrawWindow(hDlg, NULL, NULL, RDW_INVALIDATE | RDW_ERASE |<br />
RDW_UPDATENOW | RDW_ALLCHILDREN);<br />
<br />
RECT rect;<br />
GetClientRect(hAnim, &rect); <br />
InvalidateRect(hAnim, &rect, FALSE);<br />
<br />
SetTimer(hDlg, 1, 350, NULL);<br />
<br />
etc...<br />
In the timer event, I have the following code:
<br />
case WM_TIMER:<br />
KillTimer(hDlg, 1);<br />
SetTimer(hDlg, 1, 20, NULL);<br />
theMain.m_nErrCode = theMain.m_lpDevice->Communicate(hDlg,<br />
&bPercent, &wPacketCount, szStatus);<br />
<br />
etc...<br />
As you can see, I am running a communcation routine that is sending
data through the USB port using an HID driver and standard WriteFile
calls. However, when the dialog first loads up, sometimes, not all the
time, the animation will not show up immediately. I'm trying to make a
dialog like the Windows Explorer dialog shown during a long copy
operation. Is there anything that I can do to make sure that the
animation is up before running the communication?
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
Using MFC in a MDI program.
The view has no background, so nothing is painted automatically.
I have this BitBlt on the OnDraw function of a view.
CRect r;<br />
pDC->GetClipBox(&r);<br />
<br />
pDC->BitBlt(r.left, r.top, r.Width(), r.Height(), &pDoc->m_map.m_canvas,<br />
r.left, r.top, SRCCOPY);
But it doesn't seem to do anything! Not a pixel gets painted.
I tried a FillSolidRect too here and that worked fine.
m_canvas is a DC created with CreateCompatibleDC(NULL)
the rect r seems to be correct and the m_canvas seems to be a valid canvas too.
Oh and the BitBlt returns 1, so it's not failing internally it seems...
|
|
|
|
|
What are the values in r ? Are they within the bounds of the dialog ? Of the canvas ? Try making the last parameter WHITENESS and see what you get. ( You should get a white box ).
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
The m_canvas should be exactly the size of the drawing area
The values in r seem the right ones needed
WHITENESS works fine
I didn't set the size of m_canvas in any way though. Should I have? And if yes, then with what function? I couldn't find anything that would do that
|
|
|
|
|
Do you have selected a bitmap object in your "m_canvas" memory DC ?
Ohé Partisans, Ouvriers et Paysans
C'est l'alarme!
Le Chant des Partisans
|
|
|
|
|
No. BitBlt doesn't require anything specific to be selected, does it?
|
|
|
|
|
Ok, it's here probably the problem, there's no data in you document's object. Memory DCs require a bitmap which is the one with stores the graphical info.
When you create your document DC, create also a compatible bitmap (look at CBitmap::CreateCompatibleBitmap), select it in your memory DC, draw on it then BitBlt on your "device" DC.
Here a sample of the mechanic to use, extracted from a drawing method, with
m_SelectionRect = rectangle used to draw "on memory"
DrawMyObject(CDC *pDC): method which actually draws through pDC
dc: the "device" DC
CDC TempMemDC;<br />
CBitmap *pTempBitmap = new CBitmap();<br />
VERIFY(TempMemDC.CreateCompatibleDC(NULL));<br />
VERIFY(pTempBitmap->CreateCompatibleBitmap(&dc, m_SelectionRect.Width(),<br />
m_SelectionRect.Height())); <br />
CBitmap *pOldBitmap = (CBitmap *) TempMemDC.SelectObject(pTempBitmap); <br />
TempMemDC.BitBlt(0, 0, m_SelectionRect.Width(), m_SelectionRect.Height(), BLACKNESS);<br />
DrawMyObject(&TempMemDC);<br />
dc.BitBlt(0, 0, m_SelectionRect.Width(), m_SelectionRect.Height(), &TempMemDC, 0, 0, SRCCOPY);<br />
TempMemDC.SelectObject(pOldBitmap);
HTH,
Ohé Partisans, Ouvriers et Paysans
C'est l'alarme!
Le Chant des Partisans
|
|
|
|
|
Thanks, I think I get it now
|
|
|
|
|
My pleasure if I may help. And welcome on CP
Ohé Partisans, Ouvriers et Paysans
C'est l'alarme!
Le Chant des Partisans
|
|
|
|
|
Hi,
I have written this to repaint the slider channel:
NMCUSTOMDRAW the_struct;
the_struct.hdr.hwndFrom =m_ProgressSlider.m_hWnd;
the_struct.hdr.idFrom = IDC_PROGRESSSLIDER;
the_struct.hdr.code=NM_CUSTOMDRAW;
the_struct.dwDrawStage = CDDS_ITEMPREPAINT;
the_struct.dwItemSpec =TBCD_CHANNEL;
the_struct.hdc =this->GetDC()->m_hDC;
m_ProgressSlider.GetChannelRect(&the_struct.rc);
SendMessage(WM_NOTIFY ,(WPARAM)IDC_PROGRESSSLIDER,(LPARAM)&the_struct);
But slider is not repainted.Can anyone help me..
Regards
|
|
|
|
|
|
i don´t know, if i understand you right, because my english is not so good.
if you have a listCtrl in MFC, for example: m_ctrlListBox, then you can add a string to the listbox: m_ctrlListBox.AddString("Hi");
if want to to select this entry you can do something like this:
<br />
m_ctrlList.AddString("Hi");<br />
m_ctrlList.SetCurSel(0);<br />
int place=m_ctrlList.GetCurSel();<br />
CString buffer;<br />
m_ctrlList.GetText(place, buffer);<br />
now the buffer includes the first entry of the listbox.
hope i could help you.
mfc
|
|
|
|
|
i want to enter my edit box text into a list box. how it can be done? can anyone help..
himanshu
|
|
|
|
|
Are you using MFC?
CString sString = "";<br />
<br />
m_edit.GetWindowText(sString);<br />
<br />
m_listbox.AddString(sString);
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
Try this:
<br />
CListBox a;<br />
CString b = "";<br />
<br />
yourEditBox.GetWindowText(&b);<br />
a.AddString(b);<br />
Of course you can change the CString and the GetWindowText(...) for a CString variable linked to your editbox... if you want to do it in this way you must call UpdateData();
hope this helps...
|
|
|
|
|
thanks a lot..
|
|
|
|
|
Hi,
i've a problem converting data from a format to another. the function
VARIANT SaveToMemory(const VARIANT& Format, const VARIANT& CurSelection);
returns a byte array (text data) casted like a VARIANT. I need to put this array in a CString variable. So I've used this:
COleVariant varBuffer;
COleVariant mode, cur;
mode = (long)5;
cur = (short)TRUE;
varBuffer = m_txctrl.SaveToMemory(mode, cur);
CString m_text = ((CByteArray &)(varBuffer.pbVal)).GetData();
But this will return an empty string. using CString m_text = (varBuffer.pbVal); return me a single byte.
It's wrong my code?
|
|
|
|
|
Gian wrote:
returns a byte array (text data) casted like a VARIANT
Where exactly is that byte array? It can't be pbVal because this one is about one single byte... (check MSDN)
rechi
|
|
|
|
|
i've solved calculating the dimension of the OleVariant and using memcpy to copy data in a CByteArray. now works
|
|
|
|
|
hello,
i have an mfc program and an access database. i connected them with odbc.
how can i make the following sql statement in my mfc programm?
select distinct xy from mytable
i want to read out 'xy' from a table 'mytable' and put these CString into a ComboBox:
Now i tried this:
<br />
CMyDatabase db;<br />
db.Open( CRecordset::dynaset,<br />
_T( "Select distinct xy from mytable" ) );<br />
<br />
db.MoveFirst();<br />
while(!db.IsEOF())<br />
{<br />
m_ctrlCombo.AddString(db.m_xy);<br />
db.MoveNext();<br />
}<br />
db.Close();<br />
UpdateData(false);<br />
i get the error, when i want to use this funktion. the error:
error with the call of a data record
what´s wrong?????
thanks
mfc
|
|
|
|
|
You need to follow these steps:
1. Open the database (using most likely a DSN, or a connection string).
2. Create a CRecordset object that uses the above open datastring.
3. Open the CRecordse t object with a SQL query ("SELECT disintct...")
4. Once the recordset is open, iterate through recordset via MoveNext, MoveFirst etc.
Also, is wise to include everything in a try/catch block and you will most likely catch a pointer to CDBException object.
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
thanks for reply.
i tried your idea:
<br />
CMyDatabase db;<br />
db.Open();<br />
CRecordset rs (&db);<br />
but i get an error. must i include something (i included
#include "afxdb.h"
)?
thanks
mfc
|
|
|
|
|
afxdb is a standard header, so you should use angle brackets:
#include <afxdb.h>
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
yes, i use angle brackets (< >).....but it does not work.
why? can you help me????
the error is here
<br />
CRecordset rs(&db);<br />
the program has problems with &db
why?
mfc
|
|
|
|
|