|
I use SetRTF to stream an RTF string into a RichEdit control or view.. It's declared like this..
void SetRTF(CString sRTF);
static DWORD CALLBACK CBStreamIn(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb);
void CMyView::SetRTF(CString sRTF)
{
EDITSTREAM es;
es.dwError = 0;
es.pfnCallback = CBStreamIn;
es.dwCookie = (DWORD) &sRTF;
GetRichEditCtrl().StreamIn(SF_RTF | SFF_SELECTION, es);
}
DWORD CALLBACK CMyView::CBStreamIn(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CString *pstr = (CString *)dwCookie;
USES_CONVERSION;
if( pstr->GetLength() < cb )
{
*pcb = pstr->GetLength();
memcpy(pbBuff, T2CA((LPCTSTR)*pstr), *pcb );
pstr->Empty();
}
else
{
*pcb = cb;
memcpy(pbBuff, T2CA((LPCTSTR)*pstr), *pcb );
*pstr = pstr->Right( pstr->GetLength() - cb );
}
return 0;
}
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Hi:
I'm beginner in Activex programming and recently i have written a custom edit-box.But i want to add two property for Bkack-Color and
Text-Color of this editbox(m_backColor AND m_textColor).So i used the following codes in "OnDraw" function to do this:
//////////////////////////////////////////////////////////////////////
void CTextBoxExCtrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect&
rcInvalid)
{
DoSuperclassPaint(pdc, rcBounds);
CBrush *pBrush;
pBrush=new CBrush(m_backColor);
pdc->FillRect(rcBounds,pBrush);
pdc->setTextColor(m_textColor);
//----> As you know type of m_backColor And m_textColor is OLE_COLOR;
///////////////////////////////////////////////////////////////////////
the color of background successfully changed,But whenever i want to
write in editbox ,background'color change to white color.
is my methode an appropriate solution? please help me.
Please excuse me for bad comments,english isn't my native language.
Thanks a lot.
|
|
|
|
|
Not sure if this will help but you may need to handle the key down message and do a Invalidate on the control so it gets repainted.. Again this is just a guess.
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I recommend you download the source code for my article[^] and take a look how the base class handles setting/getting the text and background colors.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
I have two editboxes. I am overriding pretranslate for WM_KEYDOWN and VK_RETURN. How can I distinguish between the editboxes to see which one the user pressed enter in?
I also tried overriding OnCommand and have rthe same problem there. In fact both these are running nomatter where I hit enter on the CDialog. I only want the function to handle the enter key presses for the two edit boxes, each one individually. I tried doing GetSafeHWnd:
if ( p->GetSafeHwnd() == m_combo.GetSafeHwnd() )
where I get p from GetFocus but it never says its true.......I actually checked all the HWNDS of all the controls on my UI and none of them compared with the safeHWnd resulting from GetFocus....I think I even checked out the HWND of the UI itself too...So what is it thinking the focus is on? How can I get it to run on if its one of the two editboxes thats getting "Enter"?
Thanks
Appreciate your help,
ns
|
|
|
|
|
Did you try comparing the hwnd in the MSG object (passed into PreTranslateMessage) against the GetSafeHwnd() of the controls?
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
Just did that ...but none of them match the hwnd of pMsg..
BTW its a comobox editpart that I want to trap the enter for..
Appreciate your help,
ns
|
|
|
|
|
If it's a combo box, then the edit box is just a child window with an ID of 1001. So you can do something like:
CWnd* pEditCtrl = GetDlgItem(IDC_COMBO_WHATEVER)->GetDlgItem(1001);
You can then compare the m_hWnd of that against the hwnd of the MSG object and it should work.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
You have resolved the mystery that has been plaguing me for a week!!!!! I cant thank you enough!
Where did you learn about the 1001? Is it in MSDN ? Does the listbox part of the combo have a "code number" too? 1002?
Appreciate your help,
ns
|
|
|
|
|
Glad to have helped.
I don't recall how I learned about the edit control's ID, but I had actually forgotten that it was 1001. I knew it had some fixed number, but I couldn't remember it. So I googled for "ID of edit control of combo box" and found the answer in an article in CodeGuru.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
Hello,
I currently work on a MFC C++ application with Visual 6.0.
This application have to manage 2 screen, 1 with the main Windows display, the second have to display a bmp or jpeg picture.
Does someone know how to manage the second screen ?
Thank you !
Paul JOACHIM
|
|
|
|
|
I don't know if that's what you want but you can use a splitter window (this will divide the screen like, for example, the file explorer).
Take a look at CSplitterWnd documentation !
What kind of project do you use?? Dialog based or SDI/MDI ?? The Splitter window is easy to implement in a SDI application.
|
|
|
|
|
Thank you for your answer. But I can't use a splitter windows because I work whith a existing application and I can't change its display. I just can add a second video flow (just for display bmp and jpeg picture).
Do you have an other idee ?
|
|
|
|
|
I studied the CSplitterWnd class like Cedric proposed me, and I think my first message was not clear. When I say "I want to manage 2 screen", I mean "2 monitor". So the CSplitterWnd class is not good for me.
|
|
|
|
|
hi
i am looking to read an wav file into an activeX windows mediaplayer
i know the location of my file, but i dont know how to get it to play
it seems to open, but what do i need to do to make it play.
help....i am a novice so be gentle
this is what i have got so far, im missing the bit i need to put in the try bit
char* message = ("D:\\callparent\\new_name\\020612125252-33381.wav");
CFile myFile(message,
CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyNone);
try
{
return TRUE;
}
catch(CException* pE)
{
pE->ReportError();
pE->Delete();
myFile.Close();
return FALSE;
}
|
|
|
|
|
What is this "activeX windows mediaplayer"? Is it a control in your dialog box? How did you add it? Please provide more info.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
Use:
#include <mmsystem.h>
sndPlaySound(...)
without any fileopen, etc.
Best regards, Alex.
================================
Useful links
|
|
|
|
|
hi,
I'm developing a program that uses linked list's as a cover for the database. So i have list's of >1000 struct's. wenn i shut down my program i get memory dumps:
C:\projecten\PLCServer 0.2\DBVoorraadBeheer.cpp(63) : {3263} normal block at 0x06B95498, 44 bytes long.<br />
Data: < dU U U > 01 00 00 00 64 55 B9 06 0C 55 B9 06 BC 55 B9 06 <br />
strcore.cpp(118) : {3262} normal block at 0x06B95440, 15 bytes long.<br />
Data: < A > 01 00 00 00 01 00 00 00 02 00 00 00 41 00 00 <br />
strcore.cpp(118) : {3261} normal block at 0x06B953B8, 67 bytes long.<br />
Data: < 6 Spir> 01 00 00 00 1B 00 00 00 36 00 00 00 53 70 69 72 <br />
strcore.cpp(118) : {3260} normal block at 0x06B95360, 25 bytes long.<br />
Data: < 0700> 01 00 00 00 06 00 00 00 0C 00 00 00 30 37 30 30 <br />
strcore.cpp(118) : {3259} normal block at 0x06B95308, 25 bytes long.<br />
Data: < Cool> 01 00 00 00 06 00 00 00 0C 00 00 00 43 6F 6F 6C
how can i prevent this?
[]D [] []D []
|
|
|
|
|
Willem B wrote:
how can i prevent this?
delete all objects/memory that you allocate with 'new' and free all memory you allocate with 'malloc'.
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
is it harmfull if i let the compiler delete it?
[]D [] []D []
|
|
|
|
|
|
Willem B wrote:
is it harmfull if i let the compiler delete it?
It just won't do it: You told him that you wanted memory (new ), got it (new succeeded), and now you have to tell him that you dont want it anymore (delete ).
If you want it automatic, then don't new your variables!
|
|
|
|
|
Anything allocated with new or malloc is not "deleted" by the compiler. It needs to be cleaned up with "delete", "free", or you can just let it happen when the program exits. However, if the program runs for a while, more and more memory may continue to be allocated and eventually you'll run out of it, causing the program to crash.
The only memory the compiler cleans up automatically is the stack, which you can use to efficiently allocate any variable:
{
CString s = "allocated on the stack so it will be free automatically";
CString* p = new CString("allocated on the heap, needs to be freed with delete");
delete p;
}
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
I have a listctrl for logging. Logging can be activated or deactivated. When logging is deactivated, I want to make the text and background grayer grayer. I know how to use CustomDraw, but how do you make colors grayer? Anyone got a clue?
|
|
|
|
|
Gray is an equal combination of red, green and blue color values.
Jason Henderson "You must be the change you wish to see in the world." - Gandhi
articles profile
|
|
|
|