|
I want to set the widht of the first pane as 100. If I use the following code,
m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_STRETCH,100);
it gives me an exception. What should I use?
|
|
|
|
|
T.RATHA KRISHNAN wrote: m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_STRETCH,100);
If you want to width of first satus pane, it should be 0th index , isn't it ?
What exception it is throwing ? Have you tried debugging it ?
|
|
|
|
|
Unhandled exception at 0x7c1d71bb (MFC71.dll) in Perspective.exe: 0xC0000005: Access violation writing location 0x00000014.
If I break this, it goes to a class called
void CStatusBar::SetPaneInfo(int nIndex, UINT nID, UINT nStyle, int cxWidth)
{
ASSERT_VALID(this);
BOOL bChanged = FALSE;
AFX_STATUSPANE* pSBP = _GetPanePtr(nIndex);
pSBP->nID = nID;
if (pSBP->nStyle != nStyle)
{
if ((pSBP->nStyle ^ nStyle) & SBPS_STRETCH)
bChanged = TRUE;
else
{
pSBP->nStyle = nStyle;
pSBP->nFlags |= SBPF_UPDATE;
SetPaneText(nIndex, pSBP->strText);
}
pSBP->nStyle = nStyle;
}
if (cxWidth != pSBP->cxText)
{
// change width of one pane -> invalidate the entire status bar
pSBP->cxText = cxWidth;
bChanged = TRUE;
}
if (bChanged)
UpdateAllPanes(TRUE, FALSE);
}
What to do?
|
|
|
|
|
You have not answered my first question about index, have you passed 0th index ?
And where exactly it is crashing in above code? you are definitely using invalid pointer here.
|
|
|
|
|
Actually my requirement is to set width of the second pane only. I have told that first pane by mistake.
My initial statement,
m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_STRETCH,100);
is the right requirement only. If I use this code, I got the afore mentioned
exception.(refer last message by me).
|
|
|
|
|
Ok, At which line exactly, debugger is showing crash ?
I can run this code in sample SDI app, without any problem.
|
|
|
|
|
If I remove the comments from this line,
//m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); an exception occurs. If I break that exception, it goes to a file called barstat.cpp
void CStatusBar::SetPaneInfo(int nIndex, UINT nID, UINT nStyle, int cxWidth)
{
ASSERT_VALID(this);
BOOL bChanged = FALSE;
AFX_STATUSPANE* pSBP = _GetPanePtr(nIndex);
pSBP->nID = nID;
if (pSBP->nStyle != nStyle)
********{
if ((pSBP->nStyle ^ nStyle) & SBPS_STRETCH)
bChanged = TRUE;
else
{
pSBP->nStyle = nStyle;
pSBP->nFlags |= SBPF_UPDATE;
SetPaneText(nIndex, pSBP->strText);
}
pSBP->nStyle = nStyle;
}
if (cxWidth != pSBP->cxText)
{
// change width of one pane -> invalidate the entire status bar
pSBP->cxText = cxWidth;
bChanged = TRUE;
}
if (bChanged)
UpdateAllPanes(TRUE, FALSE);
}
The yellow pointer appears in the line where ******** is shown. What may be the problem?
-- modified at 1:27 Monday 12th February, 2007
|
|
|
|
|
T.RATHA KRISHNAN wrote: AFX_STATUSPANE* pSBP = _GetPanePtr(nIndex);
pSBP->nID = nID;
if (pSBP->nStyle != nStyle)
It may be beacuase, pSBP is NULL. Are you sure, there are two panes present in status bar ? Have you called this function after creating status bar ?
|
|
|
|
|
Yes, There are two status bar panes. I've called SetPaneInfo function after creating the Status Bar only. The code for displaying message in the status bar pane is,
void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI)
{
char str1[150];
//int len = message.GetLength();
sprintf(str1, "%s",message.GetString());
CDC* pDC = m_wndStatusBar.GetDC();
pDC->SetTextAlign(TA_RIGHT);
pCmdUI->Enable(TRUE);
//m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100);
pCmdUI->SetText((const char *)str1);
//m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len);
}
Here this line,
CDC* pDC = m_wndStatusBar.GetDC();
compiles without any problem.
This line also,
pDC->SetTextAlign(TA_RIGHT);
compiles without problem. But not displaying message right aligned.
If I remove commenting from this line,
//m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100);
then only that exception occurs.
|
|
|
|
|
Show the code, how you have created this status bar ?
|
|
|
|
|
The code for creating Status Bar is,
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1;
}
Here is the Indicators.
static UINT indicators[] =
{
0,// ID_SEPARATOR
IDS_MESSAGE,
ID_SHOWFPS,
};
IDS_MESSAGE is the ID of the second pane. The pane in which we display the message. ID_SHOWFPS is the ID of the First pane.
I display the message in some other class using the following code.
void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI)
{
char str1[150];
//int len = message.GetLength();
sprintf(str1, "%s",message.GetString());
CDC* pDC = m_wndStatusBar.GetDC();
pDC->SetTextAlign(TA_RIGHT);
pCmdUI->Enable(TRUE);
//m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100);
pCmdUI->SetText((const char *)str1);
//m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len);
}
|
|
|
|
|
T.RATHA KRISHNAN wrote: if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1;
}
I'm seeing nothing wrong with your code, its creation is succesful. May be you mail send across your sample code ay prasad.som at mail dot com.
|
|
|
|
|
Could U pls send me your correct email ID? (like this one rtr_18@yahoo.com)
|
|
|
|
|
T.RATHA KRISHNAN wrote: Could U pls send me your correct email ID?
It is correct.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
If you call,
m_wndStatusBar.SetPaneInfo(0, IDS_MESSAGE, SBPS_STRETCH, len);
is program crashing?
|
|
|
|
|
T.RATHA KRISHNAN wrote: static UINT indicators[] =
{
0,// ID_SEPARATOR
IDS_MESSAGE,
ID_SHOWFPS,
};
IDS_MESSAGE is the ID of the second pane.
Do you have an entry for IDS_MESSAGE in the stringtable resource?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I think its strange that one problem persists for such a long time...
I have some questions for you.
1. Have you used "SetIndicators" function?
>> If you are not using function, your prograam will definitely crash.
2. What is the idea behind doing these operations in a DOC class?
3. Is it possible to share the code you are using to create status bars?
thanks and regards
haribabu
|
|
|
|
|
Here is the indicators array.
static UINT indicators[] =
{
0,// ID_SEPARATOR
IDS_MESSAGE,
ID_SHOWFPS,
};
The code that is used to create status bars.
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1;
}
These two codes are in the same file only(MainFrm.cpp)
|
|
|
|
|
|
T.RATHA KRISHNAN wrote: Actually my requirement is to set width of the second pane only.
Do you have to use SetPaneInfo() to do this?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
ok i would like to make a console app be able to send a command to a nother console app and have it run it,
i use dev C++ for the compiler.
|
|
|
|
|
heyhey
so, I searched everywhere and I cannot find the right answer...
I want to do a filter of my output in OpenGl. output actually means framebuffer but perhaps I have to do the operation somewhere else.
I want to subtract parts of the color, so let's say 50% red and 20% green.
I found the way of removing all the RGB parts by glColorMask(R,G,B,Alpha) but that's not exactly what I want, because it removes the whole R,G or B part!
I could use some BlendFunc I figured out but I'm not sure how to use it.
And I would need to set a certain background color for that.
I did something with that my 3d model got transparent, too, cause I need to use the alpha channel one way or the other. And I don't want that either.
Hope you got my question cause it's buggin me now for some days
zqueezy
|
|
|
|
|
Not sure exactly what you are asking, but you may want to try glPixelTransfer().
e.g.
glPixelTransferf(GL_RED_SCALE, 0.2126);
glPixelTransferf(GL_GREEN_SCALE, 0.7152);
glPixelTransferf(GL_BLUE_SCALE, 0.0722);
would convert the RGB colours to their luminance (grey scale) value.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hi all,
Following is the problem (I provided some test code):
After runing the below sample the correct item is displayd at
the top of the list control's visible area just as I want.
The problem is that if I push the VK_DOWN or VK_UP key, the next
selected item will be the first item and not item 356 or 354 as
as you would expect from this sample.
The list will automatically scroll to the first item. However if
I click on the selected item (in this example 355) and then push
the VK_DOWN or VK_UP key it will select the correct item
(in this example 356 or 354).
This is really anoying. Could anybody please give me a hint on how
to proceed. It should be easy to solve but I just can't figur it out.
// In CMyDialog.h
CListCtrl m_cListCtrl;
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// Remove styles
m_cListCtrl.ModifyStyle( LVS_ICON | LVS_LIST | LVS_REPORT | LVS_SMALLICON, 0 );
// Add styles
m_cListCtrl.ModifyStyle(0, LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS );
// Add extended styles
ListView_SetExtendedListViewStyle( m_cListCtrl.m_hWnd, LVS_EX_FULLROWSELECT );
// Header
m_cListCtrl.InsertColumn( 0, "Col 1", 0, 100 );
m_cListCtrl.InsertColumn( 1, "Col 2", 0, 100 );
// Set LVITEM structure
LVITEM lvi;
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0;
// Adding items and subitems
for ( int i=0; i<900; i++ )
{
lvi.iItem = i;
lvi.pszText = "";
m_cListCtrl.InsertItem( &lvi );
for ( int j=0; j<2; j++ )
{
CString str;
str.Format( "Col %d, Row %d", j, i );
m_cListCtrl.SetItemText( i, j, str );
}
}
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyDialog::OnBnClickedButton1()
{
int nItemIndex = 355;
CRect rcTopItem;
CRect rcSelItem;
// Current top visible item
int nTopIndex = m_cListCtrl.GetTopIndex();
// Get bounding rectangle around the current top item
m_cListCtrl.GetItemRect( nTopIndex + 1, &rcTopItem, LVIR_BOUNDS );
// Get bounding rectangle around the selected item
m_cListCtrl.GetItemRect( nItemIndex, &rcSelItem, LVIR_BOUNDS );
// Compute the y distance between the two items
CSize sz( 0, rcSelItem.bottom - rcTopItem.bottom );
m_cListCtrl.Scroll( sz );
m_cListCtrl.SetItemState( nItemIndex, LVIS_SELECTED, LVIS_SELECTED|
LVIS_FOCUSED );
m_cListCtrl.EnsureVisible( nItemIndex, FALSE );
m_cListCtrl.SetFocus();
}
|
|
|
|
|
Zombie_Inc wrote: m_cListCtrl.SetItemState( nItemIndex, LVIS_SELECTED, LVIS_SELECTED|
LVIS_FOCUSED );
You are clearing the LVIS_FOCUSED flag for the item in the above code. Was that your intention?
If fixing that doesn't help...
What if you clear the previous focused/selected item before setting the newly selected/focused
item?
m_cListCtrl.SetItemState( -1, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|
LVIS_FOCUSED );
m_cListCtrl.SetItemState( nItemIndex, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|
LVIS_FOCUSED );
|
|
|
|
|