|
This is usually only possible with straight C libs, leaving aside the MFC issues.
I'd say build both sets and store them in different directories, and set your projects Linker settings additional library paths accordingly to locate the correct .lib files for each compiler.
Then I think you can tell the different IDEs where to find the DLL by adding the path to the UG DLLs in the Tools | Options | Directories - Executable files (for VC6) or Tools | Oprions | Projects and Solutions - VC++ Directories - Executable files (for VS2005).
Tim
|
|
|
|
|
The following code is to log events and I want to make the last row inserted shown in highlighted color to make it clearly visible among the old events. One thing is that the old highlighted row must be reset to normal background, that is, white color if it is the current default background color.
The code below inserts a new row in cyan color everytime I receive an event, but it always colors every row. How can I modify it to color the newly row only? I tried many variant ways, but couldn't make them work as I wanted. Please help.
//****** First add a new row for an event logging
int ans = m_grid1.InsertRow(0);
//****** Then set the back/text color and select the range to apply
cell.SetBackColor(RGB(0, 255, 255));
cell.SetTextColor(RGB(0, 0, 0));
m_grid1.QuickSetRange(0, 0, mr_grid1.GetNumberCols() - 1, 0, &cell);
//****** Next write the log
m_grid1.QuickSetText(0, 0, _T("T2"));
m_grid1.QuickSetText(1, 0, m_pOwner->m_AUTOBS); // AUTOBS##
m_grid1.QuickSetNumber(2, 0, ++m_pOwner->m_OrdNo);
m_grid1.QuickSetText(3, 0, ct.Format(_T("%Y/%m/%d %H:%M:%S")));
m_grid1.QuickSetText(4, 0, strStrategy);
m_grid1.QuickSetText(5, 0, strSymbol);
m_grid1.QuickSetText(6, 0, strOrdrActn);
m_grid1.QuickSetText(7, 0, strOrderType);
m_grid1.QuickSetText(8, 0, strCtgry);
m_grid1.QuickSetNumber(9, 0, nOrdrQty);
m_grid1.QuickSetNumber(10, 0, nOrdrPrice);
m_grid1.QuickSetNumber(11, 0, 0);
//****** Finally, goto to the top row and redraw to make the effect visible
m_grid1.GotoRow(0);
m_grid1.RedrawRow(0);
However everytime this code is executed, all logs are colored the same. What I want is to highlight the newly inserted row and reset the old highlighted row (that is, the second row) to the normal white/black background/text color.
Thanks
HR
|
|
|
|
|
I think what is missing in your code is the code to reset the (now second row) colors - which would need to be done for each cell in row 1.
There might be a simpler way to do this with code in OnGetCell - if new log entries are always inserted at row 0, then just adjust the colors for cells in that row in OnGetCell - this won't affect the actual cell colors, so when the cells are no longer in row 0 the default colors will show.
I'm thinking you could also set a flag that might be used to stop the highlighting after a certain period of time, for example to let the user know that nothing has happened in the log for the last n minutes, but just an idea.
This code in OnGetCell should work:
BOOL m_bNewItem = TRUE;
if(row == 0 && m_bNewItem) {
cell->SetBackColor(RGB(0,255,255));
cell->SetTextColor(RGB(0,0,0));
}
So, when adding the new cells to row 0, set the colors the way they should appear after they are no longer in row 0 and all should be well.
If you want to turn off the highlighting (say, after a timer fires) then just set m_grid1.m_bNewItem = FALSE and redraw row 0.
Tim
|
|
|
|
|
//****** First add a new row for an event logging
int ans = m_grid1.InsertRow(0);
/* => commented out
//****** Then set the back/text color and select the range to apply
cell.SetBackColor(RGB(0, 255, 255));
cell.SetTextColor(RGB(0, 0, 0));
m_grid1.QuickSetRange(0, 0, mr_grid1.GetNumberCols() - 1, 0, &cell);
*/
//****** Next write the log
m_grid1.QuickSetText(0, 0, _T("T2"));
m_grid1.QuickSetText(1, 0, m_pOwner->m_AUTOBS); // AUTOBS##
m_grid1.QuickSetNumber(2, 0, ++m_pOwner->m_OrdNo);
m_grid1.QuickSetText(3, 0, ct.Format(_T("%Y/%m/%d %H:%M:%S")));
m_grid1.QuickSetText(4, 0, strStrategy);
m_grid1.QuickSetText(5, 0, strSymbol);
m_grid1.QuickSetText(6, 0, strOrdrActn);
m_grid1.QuickSetText(7, 0, strOrderType);
m_grid1.QuickSetText(8, 0, strCtgry);
m_grid1.QuickSetNumber(9, 0, nOrdrQty);
m_grid1.QuickSetNumber(10, 0, nOrdrPrice);
m_grid1.QuickSetNumber(11, 0, 0);
//****** Finally, goto to the top row and redraw to make the effect visible
m_grid1.GotoRow(0);
m_grid1.RedrawRow(0);
and
void MyCug::OnGetCell(int col, long row, CUGCell *cell)
{
if(row == 0 && col >= 0 )
{
cell->SetBackColor(RGB(0,255,255));
cell->SetTextColor(RGB(0,0,0));
m_bNewItem = FALSE;
}
}
Now it works as I wanted. Everytime a new row is inserted the newly inserted row only gets highlited.
You said,
There might be a simpler way to do this with code in OnGetCell - if new log entries are always inserted at row 0, then just adjust the colors for cells in that row in OnGetCell - this won't affect the actual cell colors, so when the cells are no longer in row 0 the default colors will show.
=> I don't understand how the cell colors go back to the default colors when they are no longer in row 0. I thought I would have to explicitly reset the cell colors back to default colors. Please help me understand this point more clearly.
And also you said,
I'm thinking you could also set a flag that might be used to stop the highlighting after a certain period of time, for example to let the user know that nothing has happened in the log for the last n minutes, but just an idea.
This code in OnGetCell should work:
// optional - place this as member value - update on timer (?) BOOL m_bNewItem = TRUE; if(row == 0 && m_bNewItem) { cell->SetBackColor(RGB(0,255,255)); cell->SetTextColor(RGB(0,0,0)); }
So, when adding the new cells to row 0, set the colors the way they should appear after they are no longer in row 0 and all should be well.
If you want to turn off the highlighting (say, after a timer fires) then just set m_grid1.m_bNewItem = FALSE and redraw row 0.
=> I like your idea of highlighting for a few seconds using timer, but not sure where to declare the m_bNewItem and where to set timer. Could you be more specific on this point?
Many thanks
HR
|
|
|
|
|
Currently if you have a drop list where the text is wider than the cell the text gets truncated. This is obviously what you want when the drop list is closed.
However I think it would be good if the drop list widened to accomodate the longest string when the list is dropped down.
|
|
|
|
|
I have come up with some additions to CUGDropListType that will do this. Please feel free to include this in the next release (or make any modifications) if you think this is a useful feature.
(You could of course do this in the m_listBox->AddString loop instead, providing the m_listBox->MoveWindow and other right/left calculations are moved after the loop.)
New method:
int CUGDropListType::GetMaxStringWidth(const CStringList& list) const
{
int maxWidth = 0;
CDC* pDC = m_listBox->GetDC();
CFont* pFont = m_listBox->GetFont();
CFont* pOldFont = pDC->SelectObject(pFont);
int len = (int)list.GetCount();
POSITION position = list.GetHeadPosition();
int pos = 0;
while(pos < len) {
CSize sz = pDC->GetTextExtent(list.GetAt(position));
if (sz.cx > maxWidth)
maxWidth = sz.cx;
pos++;
if(pos < len)
list.GetNext(position);
}
pDC->SelectObject(pOldFont);
m_listBox->ReleaseDC(pDC);
return maxWidth + 10;
}
Then in CUGDropListType::StartDropList():
int itHeight = m_listBox->GetItemHeight(0);
if (len > 15)
len = 15;
rect.bottom = rect.top + len * itHeight + 6;
if(rect.bottom > clientRect.bottom){
dif = rect.bottom - clientRect.bottom;
rect.bottom -= dif;
rect.top -= dif;
if(rect.top <0)
rect.top = 0;
}
<code>
dif = GetMaxStringWidth(list) - (rect.right-rect.left);
if (dif > 0) {
if (len >= 15)
dif += GetSystemMetrics(SM_CXVSCROLL);
rect.right += dif;
}
</code>
if(rect.right > clientRect.right){
dif = rect.right - clientRect.right;
rect.right -= dif;
rect.left -= dif;
if(rect.left <0)
rect.left = 0;
}
m_listBox->MoveWindow(&rect,FALSE);
(Note that I have already made the changes suggested in Drop down list window too large? since I was having this problem)
Regards
Allen
|
|
|
|
|
Thanks Allen
I've filed this in the update 03 pile, where the message you referenced is also waiting patiently - looks like a useful fix.
Cheers and thanks again,
Tim
|
|
|
|
|
I would like to have grid with a transparent or semitransparent background.
There doesn't seem to a way to set the background mode for transparent.
The themes code looks like it has some support for this but there isnt any documentation on how to change values!! (the link to the ms website in the help is dead).
|
|
|
|
|
Looks like this might not be easy to implement.
Are you looking for a 'glass' like appearance? I'm kind of intrigued by what you're trying to do here.
Tim
|
|
|
|
|
I have a bitmap that I want to overlay with information from a dialog that contains a grid.
The type of the that you would use UTB's CoxBackgroundpainter class for with transparent controls.
I can send you a screen capture of some code that almost works.
I made the code that calls OnGetDefBackColor() skip printing the background if the COLOREF has any of the upper 8 bits set.
What I would like to be able to do is either set an opaque color as a background or let the background of the dialog bleed through either 100% or at some level of opacity.
An example would be to have the dialog watermarked with a company seal and a confidential company data disclaimer.
In double buffer mode it would be doable by having all pixels that are in the transparent color of the grid replaced with pixel at the same location in background before blting it back.
|
|
|
|
|
hi
in my grid i control each individual row visibility by pressing a checkbox. i toggle visibility by setting row height to zero or previous value. So far so god. Each field in under a UGCTExpand cell type. When i collapse and expand this group node my invisible row appears. i want that row not seen till i press my check box again.
What is the problem?
what is the roboust way to control visibility?
thx,
atilla.
|
|
|
|
|
Hi Atilla
Yes, there is a problem here. It may be a issue with the overall height of the group not updating properly when an individual row is resized.
Will have a look.
Tim
|
|
|
|
|
Hi Atilla
Took me a while to see this - looks like the code wasn't storing the 0 row height.
In the CUGExpandType::ExpandOrContract method change the code at line 156 to check for >= 0 , not > 0 .
if (!isOpen)
{
int height = ctrl->GetRowHeight(row);;
if (height >= 0)
{
m_mapColumnHeights[row] = height;
height = 0;
ctrl->OnRowSizing(row,&height);
ctrl->SetRowHeight(row,height);
}
}
else Tim
|
|
|
|
|
hi tim,
good catch
thx.
atilla.
|
|
|
|
|
hi,
i want to implement a row ordering functionality with my UG. When i click on spin button up and down arrows i want my current row to move up and down as well. ( i do not use drag & drop )
is there an easy way to move (cut/delete) any selected row from and paste/insert it into another selected position?
is there have a built in functionality in CUGCtrl to make row ordering an ease?
Or should i go with copying all column info for current row and use ::DeleteRow(long row) and then use ::InsertRow(long row) a new row by pasting/setting all column info into that new row?
thx.
|
|
|
|
|
hi
i've done what i needed.
here is the code block. this is the editbox OnChange handler for the spin button control. every field in my Grid is located inside a UGCTExpand group cell and each field has its order index. Lets say group has 5 fields and Field_Name has index 4. There are several groups where each group have several fields. When i press spin up-down i move current row up and down and update my field index value and current row for the next time...
void CGridPropertyDlg::OnChangeFieldOrder()
{
CUGCell cell;
if(m_bIsSpinPosSet)
{
FieldCell* curCell = (FieldCell*) GetCurrentAtiCell(m_curCol, m_curRow);
int fldIndex = curCell->m_FieldIndex;
int curPos = m_SpinFieldOrder.GetPos();
int upRange, loRange;
m_SpinFieldOrder.GetRange(loRange, upRange);
if(curPos>fldIndex)
{
FieldCell* nextCell = (FieldCell*) GetCurrentAtiCell(m_curCol, m_curRow+1);
m_pGrid->InsertRow(m_curRow+2);
for(int i=-1; i<m_pGrid->GetNumberCols(); i++)
{
m_pGrid->GetCell(i, m_curRow, &cell);
m_pGrid->SetCell(i, m_curRow+2, &cell);
}
m_pGrid->DeleteRow(m_curRow);
m_pGrid->GotoCell(0, m_curRow+1);
curCell->m_FieldIndex = curPos;
curCell->SetLocation(m_curCol, m_curRow+1);
nextCell->m_FieldIndex = curPos+1;
nextCell->SetLocation(m_curCol, m_curRow);
m_curRow++;
m_pGrid->RedrawAll();
}
else if(curPos<fldIndex)
{
FieldCell* prevCell = (FieldCell*) GetCurrentAtiCell(m_curCol, m_curRow-1);
m_pGrid->InsertRow(m_curRow-1);
for(int i=-1; i<m_pGrid->GetNumberCols(); i++)
{
m_pGrid->GetCell(i, m_curRow+1, &cell);
m_pGrid->SetCell(i, m_curRow-1, &cell);
}
m_pGrid->DeleteRow(m_curRow+1);
m_pGrid->GotoCell(0, m_curRow-1);
curCell->m_FieldIndex = curPos;
curCell->SetLocation(m_curCol, m_curRow-1);
prevCell->m_FieldIndex = curPos+1;
prevCell->SetLocation(m_curCol, m_curRow);
m_curRow--;
m_pGrid->RedrawAll();
}
}
}
hope useful for someone else,,,
atilla.
|
|
|
|
|
The Code has the correct background before the attach statement, but draws a semi random color (color stays the same for a while and then changes).
The BackGround color in cells works correctly.
I am using the latest grid code, with VST 2005,win2008 SDK library update on XP SP3.
Using the default MYCug skeleton attached to a CSTATIC in a CFormView.
Link is to MFC in Static library, not UNicode.
|
|
|
|
|
I Found the problem I linked the ole version of the library into a non ole app.
This produces NO ERRORS from the linker but messes up the VTABLE and the wrong function are getting called at several points in the code.
Example OnAdjustComponent Sizes was getting called in my code.
setFocusRect was getting called when stepping through code with the debugger.
It Would be a really good Ideas to have each version of the library define
a unique symbol and an include file that would request in your app so you can make sure you are linking to the correct code.
modified on Saturday, January 3, 2009 4:14 AM
|
|
|
|
|
mhorowit wrote: It Would be a really good Ideas to have each version of the library define
a unique symbol and an include file that would request in your app so you can make sure you are linking to the correct code.
Food for thought - I've seen this affect builds in less subtle ways.
Filed in the updates bucket - thanks.
Tim
|
|
|
|
|
m_grid1.AttachGrid(this, IDC_GRID);
m_grid1.SetUniformRowHeight(TRUE);
m_grid1.SetNumberRows(0, FALSE);
m_grid1.SetNumberCols(13, FALSE);
//******* Set Highlight Mode
m_grid1.SetHighlightRow(TRUE);
m_grid1.QuickSetText(-1, -1, _T("RecNo"));
m_grid1.QuickSetText(0, -1, _T("MC/TS"));
m_grid1.QuickSetText(1, -1, _T("AUTOBS##"));
m_grid1.QuickSetText(2, -1, _T("OrdNo"));
m_grid1.QuickSetText(3, -1, _T("Time"));
m_grid1.QuickSetText(4, -1, _T("Strategy"));
m_grid1.QuickSetText(5, -1, _T("Symbol"));
m_grid1.QuickSetText(6, -1, _T("Action"));
m_grid1.QuickSetText(7, -1, _T("Type"));
m_grid1.QuickSetText(8, -1, _T("Category"));
m_grid1.QuickSetText(9, -1, _T("Qty"));
m_grid1.QuickSetText(10, -1, _T("Price"));
m_grid1.QuickSetText(11, -1, _T("EntryID"));
m_grid1.QuickSetText(12, -1, _T("Message"));
//****** Declare a CUGCell Object
CUGCell cell;
//****** Set the heading default
m_grid1.GetHeadingDefault(&cell);
cell.SetBackColor(RGB(0,255,0));
m_grid1.SetHeadingDefault(&cell);
//****** Add a new row
int ans = m_grid1.InsertRow(0);
cell.SetBackColor(RGB(0, 255, 255));
cell.SetTextColor(RGB(0, 0, 0));
m_grid1.QuickSetRange(0, 0, mr_grid1.GetNumberCols() - 1, 0, &cell);
m_grid1.QuickSetText(0, 0, _T("T2"));
m_grid1.QuickSetText(1, 0, m_pOwner->m_AUTOBS); // AUTOBS##
m_grid1.QuickSetNumber(2, 0, ++m_pOwner->m_OrdNo);
m_grid1.QuickSetText(3, 0, ct.Format(_T("%Y/%m/%d %H:%M:%S")));
m_grid1.QuickSetText(4, 0, strStrategy);
m_grid1.QuickSetText(5, 0, strSymbol);
m_grid1.QuickSetText(6, 0, strOrdrActn);
m_grid1.QuickSetText(7, 0, strOrderType);
m_grid1.QuickSetText(8, 0, strCtgry);
m_grid1.QuickSetNumber(9, 0, nOrdrQty);
m_grid1.QuickSetNumber(10, 0, nOrdrPrice);
m_grid1.QuickSetNumber(11, 0, 0);
m_grid1.GotoRow(0);
m_grid1.RedrawRow(0);
//****** Add next row
int ans = m_grid1.InsertRow(0);
cell.SetBackColor(RGB(0, 255, 255));
cell.SetTextColor(RGB(0, 0, 0));
m_grid1.QuickSetRange(0, 0, m_grid1.GetNumberCols() - 1, 0, &cell);
m_grid1.QuickSetText(0, 0, _T("T2"));
m_grid1.QuickSetText(1, 0, m_pOwner->m_AUTOBS); // AUTOBS##
m_grid1.QuickSetNumber(2, 0, ++m_pOwner->m_OrdNo);
m_grid1.QuickSetText(3, 0, ct.Format(_T("%Y/%m/%d %H:%M:%S")));
m_grid1.QuickSetText(4, 0, strStrategy);
m_grid1.QuickSetText(5, 0, strSymbol);
m_grid1.QuickSetText(6, 0, strOrdrActn);
m_grid1.QuickSetText(7, 0, strOrderType);
m_grid1.QuickSetText(8, 0, strCtgry);
m_grid1.QuickSetNumber(9, 0, nOrdrQty);
m_grid1.QuickSetNumber(10, 0, nOrdrPrice);
m_grid1.QuickSetNumber(11, 0, 0);
m_grid1.GotoRow(0);
m_grid1.RedrawRow(0);
The above code inserts two rows and colors them. However I want to reset the background color of the second row (originally first row) to white when I insert a new row (new first row).
How can I do that please?
|
|
|
|
|
hi,
you should prepare a cell with desired attributes ( text, back, htext, hback colors etc.) and use it as default grid cell.
or you can use individualy attributed cells for each column as well.
so when grid inserts a new row it uses default grid or col attributes.
take a look at SetGridDefault & SetColDefault in UG help.
CUGCell cell;
GetGridDefault(&cell);
cell.SetBackColor(RGB(255,255,255));
SetGridDefault(&cell);
or
GetColDefault(9 ,&cell);
cell.SetBackColor(RGB(255,255,255));
SetColDefault(9,&cell);
regards.
atilla.
|
|
|
|
|
Atilla,
thanks for the answer, but I am not sure yet.
Actually, the following code is to log events whenever one happens and I want to make the last row inserted in highlighted color to make it clearly visible among the old events.
//****** First add a new row for an event logging
int ans = m_grid1.InsertRow(0);
//****** Then set the back/text color and select the range to apply
cell.SetBackColor(RGB(0, 255, 255));
cell.SetTextColor(RGB(0, 0, 0));
m_grid1.QuickSetRange(0, 0, mr_grid1.GetNumberCols() - 1, 0, &cell);
//****** Next write the log
m_grid1.QuickSetText(0, 0, _T("T2"));
m_grid1.QuickSetText(1, 0, m_pOwner->m_AUTOBS); // AUTOBS##
m_grid1.QuickSetNumber(2, 0, ++m_pOwner->m_OrdNo);
m_grid1.QuickSetText(3, 0, ct.Format(_T("%Y/%m/%d %H:%M:%S")));
m_grid1.QuickSetText(4, 0, strStrategy);
m_grid1.QuickSetText(5, 0, strSymbol);
m_grid1.QuickSetText(6, 0, strOrdrActn);
m_grid1.QuickSetText(7, 0, strOrderType);
m_grid1.QuickSetText(8, 0, strCtgry);
m_grid1.QuickSetNumber(9, 0, nOrdrQty);
m_grid1.QuickSetNumber(10, 0, nOrdrPrice);
m_grid1.QuickSetNumber(11, 0, 0);
//****** Finally, goto to the top row and redraw to make the effect visible
m_grid1.GotoRow(0);
m_grid1.RedrawRow(0);
However everytime this code is executed, all logs are colored the same. What I want is to highlight the newly inserted row and reset the old highlighted row (that is, the second row) to the normal white/black background/text color.
I am not sure how I apply your answer to the above and could you modify the above code for me?
HR
|
|
|
|
|
hi
i'm using CUGExpandType to group some rows in my grid.
i need to get cell collapsed or expanded notification but in CUGExpandType.h file there is no definition for any event.
what should i do?
thx.
|
|
|
|
|
Hi
The celltypes normally notify the grid class (m_ctrl) through the OnCellTypeNotify fn. and in this case some code should be added:
void CUGExpandType::ExpandOrContract(int col, int row)
{
CUGCtrl * ctrl = this->m_ctrl;
CUGCell thisCell;
ctrl->GetCell(col, row, &thisCell);
CellData * cellData = GetCellData(col, row);
int numberOfRows = cellData->numberOfRows;
if(m_ctrl->OnCellTypeNotify(m_ID, col, row, cellData->isOpen, NULL) == FALSE) {
}
That should give a simple notification in your derived grid's OnCellTypeNotify callback, and from there you can add WM_NOTIFY code (see messages below) to pass along the event to a view or dialog of needed.
This is a bit of a quick reply - there could be specific defines for the celltype event added to ugdefine.h etc, but this might give you something to work with.
Tim
|
|
|
|
|
hi tim
thx for nice reply,
i couldn't have checked my inbox for a while cos i was trying to find some solution on my own way.
but it seems i was done a good job cos almost the same lines of code was added to get the UGExpand cell notification in my application.
i also found a way to set UGExpand cell initial expanding or collapsing state by injecting a funtion similar to CUGExpandType::SetNumberOfRows(int col, int row, int rows)
into UGCTExpand.cpp.
nice to see similiar ways indeed.
regards,
|
|
|
|
|