|
tom groezer wrote: A multileine CEdit...
You're using MFC? Why in the world would you be bothering with sending messages then? If you really want to get one line at a time from the control, see CEdit::GetLine() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I've used a customised list control that does alternate row shading but am also reading an article on how to get red text programmatically. As I'd like this too, I have added the necessary handling of NM_CUSTOMDRAW etc (well, I've found it in the shaded row source file),
what I want to do now is
if(some member variable in my single dialog)
then write this line in red
otherwise
write it in black
since I am in the function
void CColoredListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
what I want to know is how I can "get at" the parent dialog itself that has this listcontrol within it
something like
<getatthe cmaindialog="">.accessvariable
maybe
CWnd *GetParent(); is the first part, but then how do you get at the member variable (integer array that's within the parent dialog
I then thought of something like
CTestFolderBrowseDlg* myDlg = (CTestFolderBrowseDlg*)mainDlg;
and then using mainDlg as normal, but I can't include the header for my main dialog in this source file without it complaining, so I think I'm not doing this in the proper manner
for example if I put
#include "TestFolderBrowseDlg.h"
into ColoredListCtrl.cpp
it starts complaining about
testfolderbrowsedlg.h(33) : error C2065: 'IDD_TESTFOLDERBROWSE_DIALOG' : undeclared identifier
testfolderbrowsedlg.h(33) : error C2057: expected constant expression
which aren't present without the include to TestFolderBrowseDlg, but then the cast to myDlg from CWnd doesn't work
-- modified at 12:16 Monday 11th June, 2007
|
|
|
|
|
OK, this is what I am now trying in the function from the alternate shaded list view
void CColoredListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
...
////////////
LVITEM lvi;
memset(&lvi, 0, sizeof(lvi));
lvi.mask = LVIF_TEXT;
lvi.state = 0;
lvi.stateMask = 0;
unsigned char LVtext[16];
lvi.cchTextMax = 15;
// Length of string to be copied into pszText member
lvi.pszText = (LPTSTR)LVtext;
// String buffer for pszText member
// Nota bene : starts at zero (item) and ends at 'lCols' (last subitem) :
lvi.iSubItem = 5; // 6 columns in total, I assume that means 5 is the last one, also tried 4
// Retrieve the text in an item or a subitem of line 'i' :
mainDlg->SendMessage(LVM_GETITEMTEXT, (WPARAM) 0, (LPARAM) &lvi);
CString resultText(LVtext);
if(!strcmp((LPCSTR)LVtext, "Failed"))
{
do stuff...
}
///////////
it's never going into the do stuff bit. "Failed" is definitely being written/drawn in the listview report in the last column as per a SetItem call.
It would be easier if I could work out how to just get at data belonging to the dialog class itself that holds the listview control, but failing that, am not sure what I am doing wrong here.
|
|
|
|
|
ldsdbomber wrote: mainDlg->SendMessage(LVM_GETITEMTEXT, (WPARAM) 0, (LPARAM) &lvi);
The wParam should be the index of the item - are you always looking at item 0?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
no, I tried passing iRow first and that didn't work either (iRow presumably is the right parameter)
void CColoredListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR;
int iRow = lplvcd->nmcd.dwItemSpec;
switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT :
{
*pResult = CDRF_NOTIFYITEMDRAW;
return;
}
// Modify item text and or background
case CDDS_ITEMPREPAINT:
{
// ACCESS errTable here, and change font accordingly
CWnd* mainDlg = GetParent();
// CTestFolderBrowseDlg* myDlg = (CTestFolderBrowseDlg*)mainDlg;
////////////
LVITEM lvi;
memset(&lvi, 0, sizeof(lvi));
lvi.mask = LVIF_TEXT;
lvi.state = 0;
lvi.stateMask = 0;
unsigned char LVtext[16];
lvi.cchTextMax = 15;
// Length of string to be copied into pszText member
lvi.pszText = (LPTSTR)LVtext;
// String buffer for pszText member
// Nota bene : starts at zero (item) and ends at 'lCols' (last subitem) :
lvi.iSubItem = 5;
// Retrieve the text in an item or a subitem of line 'i' :
mainDlg->SendMessage(LVM_GETITEMTEXT, (WPARAM) iRow, (LPARAM) &lvi);
CString resultText(LVtext);
if(!strcmp((LPCSTR)LVtext, "Failed"))
{
do something here...
}
///////////
lplvcd->clrText = RGB(0,0,0);
// If you want the sub items the same as the item,
// set *pResult to CDRF_NEWFONT
*pResult = CDRF_NOTIFYSUBITEMDRAW;
return;
}
// Modify sub item text and/or background
case CDDS_SUBITEM | CDDS_PREPAINT | CDDS_ITEM:
{
if(iRow %2){
lplvcd->clrTextBk = m_colRow2;
}
else{
lplvcd->clrTextBk = m_colRow1;
}
*pResult = CDRF_DODEFAULT;
return;
}
}
}
|
|
|
|
|
>>lvi.iSubItem = 5; // 6 columns in total, I assume that means 5 is the last one, also tried 4
Also. subitems are 1 based. If you have 6 columns, subitem 6 is the last column.
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi,
I am making one application in VC++.NET. I want to pass one integer parameter to one thread function. How can I pass parameter to thread functions? My code is as below.
Thread function
public class TestThread
{
public:
static void ThreadProc()
{
...
}
};
Thread function call
Thread* myThread = new Thread(new ThreadStart(&TestThread::ThreadProc));
myThread->Start();
I want to pass one integer parameter in ThreadProc() .
Thanks in Advance
Priyank Raval
|
|
|
|
|
a global variable could to the job. Or has the ThreatStart-class overloaded constructors?
Greetings from Germany
|
|
|
|
|
Global variable?? NO! This is C++! Derive a class from Thread and you can make whatever
constructor and add whatever member variables you want
*EDIT ack it's sealed
Mark
-- modified at 13:05 Monday 11th June, 2007
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I still stand by my "this is C++ response
I thought Nish would have this covered...
How to pass data to worker threads[^]
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
hi priyank please ask vc.net related question here[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
If you have a standard dialog control and you've done some code for it, but then find a custom control that's based on that, is there an easy way to make the control be of that new class, eg I've done something with a listview but if i wanted to try the alternate shaded row control, can I quickly/easily do that, or is it going to get so messy it's best to start with a new custom control?
http://www.codeproject.com/listctrl/coloredlistctrl.asp[^]
|
|
|
|
|
In fact I just changed the class type in the dialog header file in one line and it worked just fine. I suppose that's because in this case, the class is just the base class with an overridden draw/erase method
|
|
|
|
|
I have a timer handle which does some idle checking. Based on the idleness of the user, I want to do certain updates in the GUI. However, I do not wish to do certain GUI updates IF there is a modal loop active (typically a dialog box open).
Is there a good and generic way to detect this condition using MFC?
|
|
|
|
|
hi...
I am using IOCP technology for my project. in some of the sites i have seen, that in windows 98, this wont be work...,If its so,
then which are technology is available for supporting(chat) in win 98
also....
Is any one knows in GOOGLE TALK and YAHOO messanger which technolgy they are using for communication........?
-- modified at 9:32 Monday 11th June, 2007
|
|
|
|
|
If you're referring to IO Completion ports then I can confirm they're only available as part of the Operating System on NT based Windows, NT, 2000, XP, Vista.
This doesn't stop you implementing something similar yourself with a thread pool and synchronisation objects, It won't be as fast or efficient but lets face it, neither is Win98
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
|
How does one convert SYSTEMTIME to char *
Many Thanks
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: How does one convert SYSTEMTIME to char *
Use <code>COleDateTime .
SYSTEMTIME sysTime = { 0 };
GetLocalTime( &sysTime );
COleDateTime odtDtTime( sysTime );
CString csTime = odtDtTime.<code>Format</code>(_T("%A, %B %d, %Y"));
|
|
|
|
|
|
Programm3r wrote: How does one convert SYSTEMTIME to char *
Outside of MFC, sprintf() will work just fine.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
|
Programm3r wrote: if (CompareFileTime((FILETIME*)dateCreated, &ftCreate)==0)
The first argument should be a pointer to a FILETIME structure. You have a char that has been cast to such.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This will work:
wsprintf(lpszString, "%02d/%02d/%d %02d:%02d:%02d",stCreate.wYear, stCreate.wMonth,
stCreate.wDay,stCreate.wHour, stCreate.wMinute, stCreate.wSecond);
if (strcmp(dateCreated, lpszString)==0)
{
...
}
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|