|
how I can change the tiltle Bar, StatusBar and Dialog BackGround Color....
Thanks In advance
|
|
|
|
|
For dialogs (and even StatusBar??) you can implement CWnd::OnCtlColor , there reacting on CTLCOLOR_DLG. If this doesn't work for status bars you could try OnEraseBackground .
And what about title bars? I remember that I've seen some articles about that here on CP;)
|
|
|
|
|
BOth Not works,
OnEraseBackground errases background, but how I set new background eg (Dialog with RED background)
|
|
|
|
|
OnCtlColor works for sure when used for dialogs. Here's an example:
HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
switch (nCtlColor)
{
case CTLCOLOR_DLG:
{
CBrush* back_brush;
COLORREF color;
color = (COLORREF) GetSysColor(COLOR_BTNFACE);
back_brush = new CBrush(color);
return (HBRUSH) (back_brush->m_hObject);
}
}
return(CDialog::OnCtlColor(pDC, pWnd, nCtlColor));
}
And a solution for OnEraseBackground could look similar to this:
BOOL CSampleView::OnEraseBkgnd(CDC* pDC)
{
CBrush backBrush(RGB(255, 128, 128));
CBrush* pOldBrush = pDC->SelectObject(&backBrush);
CRect rect;
pDC->GetClipBox(&rect);
pDC->PatBlt(rect.left, rect.top, rect.Width(),
rect.Height(), PATCOPY);
pDC->SelectObject(pOldBrush);
return TRUE;
}
*both examples taken fom MSDN and slightly modified
|
|
|
|
|
yes u are right...OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
works well,....
UPDATES In Initial Requirements.... ;P
Now I want to change the Background of Property Sheet.
OnCtColor works well for property pages, but not works for Property Sheet...
ALthough Property Sheet to inherit from CWnd....
|
|
|
|
|
Hello:
I am in the midst of trying to make a small dialog based application that has an interface to a COM port. I need to be able to display the data that comes from the COM port into a text type box that is organized in specific rows and columns similar to a terminal display. I have tried to use an edit control, a static text box and other types of controls but none give me the features I need. I am curious as to whether anyone has any idea of where I can start with this project in order to get it off the ground.
Here I list the requirements that are needed for this text display area...
- It needs to permit me to use a fixed width pitch for the characters so that distinct columns are produced. It would be nice of the actual font used is selectable but that is not a requirement.
- The text area needs to be accessable to dynamically determined row and column positions of the array so that a text string can be displayed.
- Any given part of the text needs to be able to be displayed in an alternate color scheme. Ideally the effect that needs to be achieved is to make certain text appear as reverse video to the rest of the text in the box.
- It is not really necessary for there to be any kind of cursor in the text area for "user entry of data. Just think of this text area as a display field.
- The control mechanism needs to be able to function as a control on a dialog.
I am somewhat experienced with creating windows applications but so far all my work has been with dialog based applets. The current project is one of this type and the request for help here is to try to add a small display window to the dialog that works somewhat like the text box of a HyperTerminal window with regards to the display of data characters that will be arriving from a serial port.
Any help, discussion, pointers, or sample code would be extremely helpful to me.
Note that I am working in a Win32 environment with MFC and Visual C++ Ver 6.
Thanks
Mike Karas
-
|
|
|
|
|
use a list control that does what u r looking for..and it also displays in rows and colums..search for more on list in CP and u will find many such articles...
cheers
Himanshu
|
|
|
|
|
I have looked at all the CList control articles on this web site and tried to study each carefully. I cannot directly see how a list control would be used to simply display a box of text. I did see one article about using the CustomDraw features of the List Control - but that seems way over kill to me....... does it need to be this complicated to support a terminal emulator screen at 25x80 characters with just a reverse video attribute capability?
Michael Karas
|
|
|
|
|
I would think about a "owner drawn" control. You derive a CStatic in which you Paint yourself. Then you need a output, for which you make such a control in your dialog resources.
It´s a lot of work, but you´ll should enjoy it.
Try this @ home. (B&B)
|
|
|
|
|
Thanks for the suggestion.....unfortunately I have no idea where to start in order to implement such a control. Can you make a suggestion where I can see a sample CStatic control in "Owner Drawn" mode that supports multiple lines (25 in my case) where the string for each row would be independent and each row need to be displayed in a manner with some text in normal video (black char on white background) and some characters in reverse video (white char on black background)?
Michael Karas
|
|
|
|
|
It is very simple you drawing in the Onpaint message handler evry thing. with Texout and so on. There is the CDC class which will help you.
Try this @ home. (B&B)
|
|
|
|
|
Does anyone have a code snippet (or can describe) how to load contents of a file into an object that exposes the interface IStream? The idea is I want to be able to pass an IStream which can be used to read the contents of this file. There does not need to be a direct link between the interface and the file - I need to load the file's contents into the object and access the aforementioned contents using IStream..
TIA!!
|
|
|
|
|
One implementation looks like :
CreateFile() and ReadFile() to open and read the file contents. Then create a new IStream(CreateStreamOnHGlobal()) and then
pStm->Write();//write file contents
I haven't checked this out. but theoritically this ought to work. These is also the new SHStreamOnFile() function that seems to do what we want.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - PocketPC New menu
Office addin
|
|
|
|
|
Thanks, Amit.
That, in fact, does work. I had discovered it a couple of weeks ago (I forgot to follow-up on my question). Once you've got a memory buffer and a corresponding HGLOBAL, you can use CreateStreamOnHGlobal to generate an instance of a stream object with an IStream interface.
Thanks!
|
|
|
|
|
Yes, I tried it too. Now let us suppose we were to write something like StreamFromFile([in] LPCTSTR szFile,[out,retval]IStream *ppStream). I can only see a related MAPI utility function and an shlwapi 5.0+ function SHStreamFromFile(). The implementation I guess is no longer a mystery.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - PocketPC New menu
Office addin
|
|
|
|
|
hi,
how do i change the titlebar text of a sdi program? i want the titlebar to display "My program", not "My program - Untitled".. is there a way to make the windows not displya "- Untitled"? i tried modifying idr_mainframe, but that didn't work.. thanx in advance..
|
|
|
|
|
|
thx for the help, once again.. mike.
|
|
|
|
|
I know this sounds crazy but I'd like to build an application that will allow we to modify other applications' icons. I have an application that generates other small exe files and I want to allow users to select or paste an icon into my configuration app for them. Is there an API for this ? Any ideas about how to do this ? I want to do it in VC++
Thanks,
Matt
|
|
|
|
|
take a look at the UpdateResource() function
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Hi,
I'm trying to get the source code of a web page.
It usually works fine, but on some web pages, like www.altavista.com or www.aol.co.uk I get something else. it looks like the server is sending something to 3rd party sites, and althoguh I can see in the browser the correct page, my code gets another page, completly different.
I use the WebBrowser2->get_Document
then IHTMLDocument2->Get_body and then ->Get_outterHtml
I read the page when DISPID_DOCUMENTCOMPLETE is fired.
Any ideas how can I get the real page from this sites and not the redirected one ?
(remark - on explorer 5.0 I got the correct page I think..., it looks like explorer 6.0 change something in this matter).
Regrads,
Dani.
|
|
|
|
|
Try using sockets. If you use sockets the same way as internet explore does let me explain how you could telnet to a website and thus retrive the HTML data as "internet explorer" does. You would telnet to a website and then send the text string of "GET index.html HTTP/1.0" Without quotes. Basically that is what we call a header that is sent to a website. So if you were to want to use this to make an app to get to a website simply connect to the website on port 80 and send the string get index.html HTTP/1.0 or HTTP/1.1 depending on server. Using this is how websource is retrived.
- LiquidKnight
|
|
|
|
|
You are getting the code that is received by IE after it formats it. If you want to get the unformatted code Look into the IPersistStream interface. The code will look something like this:
HRESULT GetDocumentContent(CComBSTR &bstrHTMLText)
{
bstrHTMLText.Empty();
CComPtr<IDispatch> pDisp;
HRESULT hr = m_spWebBrowser2->get_Document(&pDisp);
if (FAILED(hr))
{
return hr;
}
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spHTML = pDisp;
if (spHTML)
{
CHAR *szData = NULL;
OLECHAR *htmlText = NULL;
try
{
CComQIPtr<IPersistStreamInit, &IID_IPersistStreamInit> spData = spHTML;
CComPtr<IStream> spStream;
::CreateStreamOnHGlobal(NULL, TRUE, &spStream);
spData->Save(spStream ,FALSE);
STATSTG stat;
spStream->Stat(&stat, STATFLAG_NONAME);
szData = new CHAR[stat.cbSize.LowPart];
ULONG length;
LARGE_INTEGER pos;
pos.QuadPart = (__int64)0;
spStream->Seek(pos, STREAM_SEEK_SET, NULL);
spStream->Read(szData, stat.cbSize.LowPart, &length);
htmlText = new OLECHAR[length];
::MultiByteToWideChar(CP_ACP, 0, szData, length, htmlText, length);
bstrHTMLText = htmlText;
}
catch (...)
{
}
delete[] htmlText;
delete[] szData;
}
else
{
}
return S_OK;
}
This function is taken from a class that I wrote, so you may need to rework it a little.,
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
anyone know of any samples for detecting multiple displays, and more so, which display the app is on?
any help or pointers in the right direction are appreciated
shotgun
|
|
|
|
|
GetSystemMetrics(SM_CMONITORS) will give you the # of monitors installed. Use MonitorFromRect() to tell which monitor a window is on (or which monitor it is mostly in, if it spans more than one)
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|