|
I have an SDI MFC application. I've created the UI similar to the MSDN with a tab control in the left splitter and then in the right I have ActiveX controls and such that the user interacts with. Now, when the user for instance goes to the 'Contents' tab and opens one of the items I want to create a dynamic splitter to show that information. I don't however want to destroy the control in the other splitter window. So, basically when they select an item in the 'Contents' tab it sets the controls window to a size of zero and sets the other page to full size. The problem I have is closing the contents item and redisplaying the control window. I wanted to do something like an MDI where the user can click on the close button and it will set the contents to a size of zero and set the control to full size. Can anyone shed some light on if it's possible to place an MDI type close button in an SDI application?
Thanks for any help,
Craig
|
|
|
|
|
Hello, I'm a novice VC++ developer that would like to know how to change the background color of an edit control that has been marked as read-only.
Thank you in advance.
|
|
|
|
|
I think you want to override WM_CTLCOLOR for read-only edit controls the same as for other edit controls. There are some Microsoft Knowledge Base articles about it.
I know that the CodeGuru web site has some articles about changing colors and I assume that the CodeProject does too. Also see the MFC technical article "TN062: Message Reflection for Windows Controls" for an example.
See the bottom of http://home.socal.rr.com/samhobbs/Technical/ for my little description of the Microsoft Knowledge Base. You probably have a copy of the Knowledge Base that was provided with Visual C++ but I do not know if it is. Perhaps it is only supplied with the MSDN. In step 1, select "Visual C++". In step 2, use the default (keyword search using all words). In step 3 ("My Queston is"), enter "WM_CTLCOLOR".
|
|
|
|
|
Sam Hobbs is correct.
A sample would be :
1) add the WTL_CTLCOLOR message to your dialog.
This will create a function :
HBRUSH YOUR_DIALOG::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
2) say you want to change the background color
of IDC_EDIT9 to yellow [ RGB(255,255,0) ]
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
COLORREF m_clrBack;
CBrush m_brush;
if (pWnd->GetDlgCtrlID() == IDC_EDIT9)
{
m_clrBack = RGB(255,255,0);
pDC->SetBkColor(m_clrBack);
m_brush.CreateSolidBrush(m_clrBack);
return (HBRUSH)m_brush.GetSafeHandle();
}
else
return hbr;
|
|
|
|
|
The control that must be painted has more than one line and in this way only gets painted the first line.
I wouldn't like to abuse, but I'm just a novice and I need help...
Thank you for your comprehension and help.
|
|
|
|
|
this is the info. I can give to you:
the edit control is created at runtime:
if (!m_cedText.Create(WS_CHILD | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_READONLY,CRect(0,0,0,0),this,IDC_EDTEXT))
{
TRACE0("Error en la creació de l'EditBox per a la finestra dockable DlgBarDockSessio.\n");
return -1;
}
m_cedText.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
m_cedText.SetFont(TCCApp.GetDefaultTextFont());
And as in the sample I have processed the WM_CTLCOLOR message:
HBRUSH hbr = CDockingBarWnd::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
COLORREF m_clrBack;
CBrush m_brush;
if (pWnd->GetDlgCtrlID() == IDC_EDTEXT)
{
m_clrBack = RGB(255,255,255);
pDC->SetBkColor(m_clrBack);
m_brush.CreateSolidBrush(m_clrBack);
return (HBRUSH)m_brush.GetSafeHandle();
}
else return hbr;
PD: Thank you for your help Phil.
|
|
|
|
|
I get the date from my CMonthCalCtrl like this:
CTime CurrentCDate;
CString CurrentSelectedDate;
//Get the currentselected date
KalenderControl2.GetCurSel(CurrentCDate);
CurrentSelectedDate.Format(_T("%02d / %02d / %02d"),CurrentCDate.GetDay(),CurrentCDate.GetMonth(),CurrentCDate.GetYear());
//Put it in a box
SetDlgItemText(IDC_CURRDATE2,CurrentSelectedDate);
This gives me a f***ed up date, days +13 (in win 2000) and days +8, months +3 in win95/98. I need help on this please, what am I doing wrong that the output is wrong?
Thanks in advance,
Tom Cornille
|
|
|
|
|
Hi,
how can i get the active view (or the active document) from a non-modal dialog?
I have tried
CFrameWnd *pFrame=GetParentFrame();
CDocument *pDoc=pFrame->GetActiveDocument();
and
CView *pView=pFrame->GetActiveView();
but both, GetActiveDocument() and GetActiveView() return NULL although there was a document (and therefore a few, too) created.
I'm working with MDI docs/views.
Thanks for your help!
Chris.
|
|
|
|
|
Instead of
CFrameWnd* pFrame = GetParentFrame();
try
CFrameWnd* pFrame = (CFrameWnd*) AfxGetMainWnd();
|
|
|
|
|
I just tried that, but i still get NULL for pFrame->GetActiveView() and GetActiveDocument()!??!
|
|
|
|
|
From MSDN:
[CFrameWnd::GetActiveView ]
"This function returns NULL when called for an MDI main frame window (CMDIFrameWnd). In an MDI application, the MDI main frame window does not have a view associated with it. Instead, each individual child window (CMDIChildWnd) has one or more associated views. The active view in an MDI application can be obtained by first finding the active MDI child window and then finding the active view for that child window."
There is also an example of code.
Cheers,
Paolo.
|
|
|
|
|
- i have downloaded DDK98 and i have VC6.0
- Someone to guide me how to start writing Driver for myself designed PCI Interface Card.
- I have a 128K FIFO on my card and i just want to read/write this FIFO when required.
- Now I have to run my code at Prot. Level 0, to get it done. if u know something 4 me, or the urls on web.
|
|
|
|
|
Hello All,
After I do a FindItem on a CListCtrl, It returns an int. How do I use this int to scroll and hightlight the row to make is visible to the user?
There is a Scroll method but it take a CSize, Do I have to convert the int to CSize?
Thanks,
Tony
|
|
|
|
|
Call CListCtrl::EnsureVisible() to scroll a row into view.
|
|
|
|
|
Hi,
I would like to communicate with the serial port in my app. I think the best way is to create a worker thread accessing the serial port and filling in a CString object (something like a buffer) with the incoming characters. It must also be possible to send chars to the connected hw.
I was looking for a class implementing serial port accesses and I got PJNaughter's one. It seems to be quite well implemented but I cannot figure out how to use it in such a working thread. Is it possible to trap messages? How can I now when I have to read on the serial port? Must it be a forever loop or can it be implemented within the Windows Messages Routing?
Please help me.
|
|
|
|
|
Hi,
I don't know exactly how the class looks like but you must have some function to notify you when an event occured.
Should be somenthing like "WaitForEvent" with some parameters (event mask and timeout).
You must wait until an event like CHAR_RECEIVED occures or timeout expires .. Something like that.
General flow is something like this:
Without handshake :
- if you don't locate this kind of function to do the job for you try this :
read the port with timeout and if char received is TIMEOU_CHAR or something like this -> you didn't receive something and try again, when first valid char occures you start to construct your message. Use this on thread and be carefully with your time out values.You should have some predifined types for TIMEOUT_CHAR.
To send is much more easier, just send it.
with handshake :
- RTS/CTS, DTR/DTS or XON/XOFF you should read the protocols first and you should find functions to acces this signals from comm port.
But the genereal flow is the same. This signals helps you to know when you can send something via serial port (if device is occupied and cannot receive will raise the CTS signal ..... ).
i hope it's helpfull for you.
|
|
|
|
|
How can I open an existing WAB file and create a new WAB file?
|
|
|
|
|
I realize that this isn't exactly on subject, but I didn't see a database forum. SQL Server 2000 is supposed to have something called Federated Databases which is supposed to spread a database out over several machines, sort of like drive striping. The number of machines is supposed to be variable on setup, and reconfigurable later. Oracle has something similar called Distributed Access, but it is supposed to work differently. Does anyone have any information about a comparison between the two and which is better for what type of operations?? Thanks for your time.
|
|
|
|
|
I realize that this isn't exactly on subject, but I didn't see a database forum. SQL Server 2000 is supposed to have something called Federated Databases which is supposed to spread a database out over several machines, sort of like drive striping. The number of machines is supposed to be variable on setup, and reconfigurable later. Oracle has something similar called Distributed Access, but it is supposed to work differently. Does anyone have any information about a comparison between the two and which is better for what type of operations?? Thanks for your time.
|
|
|
|
|
i need to wright a checkers board in mfc
|
|
|
|
|
Sounds like homework! What is it you want help with?
|
|
|
|
|
Hi, I am in a problem:
An application works just fine, but:
As soon as I extract my resources into a resource-only DLL only the dialogs with standard-controls continue to load. (Therefore it is clear, that at least the app finds its resource-DLL.)
Every dialog containing CUSTOM CONTROLS fail to load:
In CDialog::DoModal() the call to CreateDlgIndirect() returns FALSE, as a result the creation is simply stopped.
I tried this with several examples from this site, the behaviour is the same...
I assume that somehow the app must get to know there are custom controls in the DLL, but how?
Any hints??
Greetings, Martin
|
|
|
|
|
Did you call AfxSetResourceHandle() to tell the framework you are using an external resource dll?
If not, load the dll with LoadLibrary() and then pass the handle to AfxSetResourceHandle() in your InitInstance override.
If you are already doing it, I don't know what's the problem.
Cheers,
Paolo.
|
|
|
|
|
Hello Paolo,
thank you for your time.
I got this code from MSDN, which should do the job:
m_hInstDLL = ::LoadLibrary("ExtRes.dll");
if ( !m_hInstDLL )
{
return FALSE; // failed to load the localized resources
}
else
{
AfxSetResourceHandle(m_hInstDLL); // get resources from the DLL
}
As I wrote, it works with simple elements, it only fails with custom controls and ActiveX-controls.
Must I tell the DLL that it has to use these? Or the App, that the DLL uses it? HOW???
Martin
|
|
|
|
|
Hi Martin,
I'm sorry, but I can't tell you more. I never tried to use a resource DLL.
I also saw your previous message "difference of custom controls from NT to 9x". I replied just to be sure you was using the 'recommended' method.
When I have some time, I will do an experiment.
As for now, maybe you will have better luck with more experienced programmers. I hope
Cheers,
Paolo.
|
|
|
|