|
Hello,
I am writing an email application using a listview control to show the messages, and I wish to change background colour to show which items have been read. Therefore I need to change a listview row background colour after it has been selected for a certain time. Outlook Express changes from bold to normal text in a similar fashion.
I have been looking at articles in CodeProject and other sites, and they show you how to change colour for a row when the control is initially being drawn (using customdraw), but I can't find anything to show how to change a row AFTER it has first been drawn (ie dynamically).
Does anyone know how to do this??
Many thanks,
Paul Trimming
|
|
|
|
|
trimtrom wrote:
and they show you how to change colour for a row when the control is initially being drawn (using customdraw), but I can't find anything to show how to change a row AFTER it has first been drawn (ie dynamically).
It's basically the same. You just set a flag according to which rows are drawn using particular colors. When you wanna change a row's color, set the flag for that row, say you have an array of flags, and then force a repaint of the control.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nish,
Thanks very much. It works of course. I didn't know it was so simple!!
Trimtrom
|
|
|
|
|
I am writin a simple ODBC application in Visual C++ to manipulate data from an Access database file. I have a memo field in the Access DB and a multiline edit control in the app. When I try to write a larger text (more than 256 symbols), and try UpdateData(), I get the following error message:
"Please enter no more than 256 characters."
I tried to set the control's max. text limit by calling CEdit::SetLimitText(64000) for example, but it did not work...
If you have any clue, please respond asap...
Thanks!
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
Vladimir Georgiev wrote:
If you have any clue, please respond asap...
Looks like you have set a DDX limit on the edit control. Verify this using class wizard if you are using VC++ 6.0, if VC++.NET check the DDX message map
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nishant, I am using VC++ 6.0. I have not set any limit (Maximum
Characters box in "Member Variables" tab). this field is empty. Is this the
correct place I am looking in?
If you have any other idea, please let me know...
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
Can you post more code? The fact that you get this mesgbox only when you call UpdateData was what prompted me to think that it is a DDX check. With the existing info I dont really have any other smart ideas. Perhaps more code will make things clearer.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Here is the function and the place it fails:
void CContactsView::OnSave()
{
UpdateData(true); //---------------> ERROR HERE!
m_pSet->AddNew();
if (m_pSet->CanUpdate()) {
m_pSet->Update();
}
if (!m_pSet->IsEOF()) {
m_pSet->MoveLast();
}
m_pSet->Requery();
UpdateData(false);
}
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
Vladimir Georgiev wrote:
UpdateData(true); //---------------> ERROR HERE!
Maybe you should set a DDX limit to not get the default limit?
Just an idea...
|
|
|
|
|
I tried that using Class Wizzard. Did not work...
|
|
|
|
|
|
Hi there!
I'm having some trouble using mutexes, and since a mutex is a semaphore with only one resource, my frist idea was to use it, but it seems that or the mutex is not well implemented or i am using it in a bad manner...
For instance, if i use the following code:
<br />
CSemaphore s1(1,1,"S1")<br />
if (s1.Lock(500))<br />
{<br />
CSemaphore s2(1,1,"S1");<br />
if (s2.Lock(500))<br />
{<br />
TRACE("\n Semaphore failed!");<br />
}<br />
<br />
s1.Unlock(1);<br />
}<br />
... i never get to see the trace message in the display! But, if use:
<br />
CMutex m1(TRUE,"M1")<br />
if (m1.Lock(500))<br />
{<br />
CMutex m2(TRUE,"M1");<br />
if (m2.Lock(500))<br />
{<br />
TRACE("\n Mutex failed!");<br />
}<br />
<br />
m1.Unlock(1);<br />
}<br />
I Always see the trace message... even if i change the initial ownership of the mutex.
Can anyone, please, show me the right way to do it with mutexes?
Thanx for your time!
|
|
|
|
|
almc wrote:
and since a mutex is a semaphore with only one resource
Where did you get that idea from?
Hint: Your assumption is wrong.
|
|
|
|
|
Straight from the CreateMutex docs:
The thread that owns a mutex can specify the same mutex in repeated wait function calls without blocking its execution. Typically, you would not wait repeatedly for the same mutex, but this mechanism prevents a thread from deadlocking itself while waiting for a mutex that it already owns. However, to release its ownership, the thread must call ReleaseMutex once for each time that the mutex satisfied a wait.
|
|
|
|
|
sigh.. ok.. another problem I don't seem to understand..
sorry.. I'm a little new to MFC and Win Programming..
Ok.. I'm trying to follow along in this book "Microsoft Visual C++ Fith Edition" to create multiple views
Now the example from the book (Ex20c) compiles and works fine.. but when I try to re-create it.. I get 3 errors when I compile
error C2143: syntax error : missing ';' before '*'
error C2501: 'CMVSampleDoc' : missing storage-class or type specifiers
error C2501: 'GetDocument' : missing storage-class or type specifiers
I get these errors when I add the View Header files to the MainFrame implementation file (CMainFrm.cpp)
I can not for the life of me figure out why I am getting these error messages.. The first error message relates to the GetDocument() function in the view.
I tried two different ways.. first I used ClassWizard to create a new class derived from CView.. and I got these errors.. so I did it exactly the way the book did it.. and just copied the .h and .cpp file to new names, and modified them with different names.. thinking that maybe because the second view was avalible from ClassWizard that funked something up.. but I still receive the errors.
Any Ideas?
|
|
|
|
|
wtf ?!?
It appears that I only get errors when I try to have a View derived from CListView..
I successfully got the code to work with two CViews.. and a CView and CHTMLView.
|
|
|
|
|
Try to include the document class header in the view header. I got a similar problem before and solved it that way.
#include "MVSampleDoc.h"
.
.
.
|
|
|
|
|
Sir....I am facing one serious problem of memory leakage. I have developed one dialog based application. In that I have made one class named "CListener" derived from CWinThread. In the InitInstance() function of that class, I have added functionality which I want to perform in separate thread. From the dialog class's OnInitDialog() function I have made the following function call to run the thread.
AfxBeginThread(RUNTIME_CLASS(CListener));
All are working fine.....But when I close application Visual C++ IDE show me some memory leackage.....
Whould you please show me the way to escap from this problem....
C.R.Naik
|
|
|
|
|
How are you closing the thread? If you start the thread and close the app while the thread is still running you will get a memory leak.. In UI Threads I try to have the thread terminate it's self.. with a PostQuitMessage(0).
Rob
|
|
|
|
|
I have a Cdialog with a CListCtrl in it that sizes along with the CDialog(MoveWindow). Theres text in the list, plus scrollbars. Whne the user lengthens the CDialog, the scrollbars eventaully vanish. AT this point I want the window to not be able to lengthen any further. How do I find out when the scrollbars have disappeared. I didnt see anything like BOOL ScrollBARsExist() or something like it in MSDN...maybe I need to get the height of the text in the cListctrl but how do I figure out that?
Also theres no OnGEtMinMAxInfo for a CDialog...so what tells it to have a max limit?
|
|
|
|
|
override ::OnSizing(...)
(don't forget to add the ON_WM_SIZING() handler in your message map).
|
|
|
|
|
Thanks! Any hints about detecting the vanishing of the clistctrl scrollbars?
|
|
|
|
|
compare GetScrollPos() and GetScrollLimit().
|
|
|
|
|
WM_GETMINMAXINFO certainly works for dialogs, although it might not appear in the ClassWizard so you'll need to add the message map entries yourself.
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
i use courier new or verdana size 9
|
|
|
|