|
The main diff btn global and static variable is u can use static variable in one file and within the scope while global variable u can use thro out the program using extern keyword, u cant use extern keyword with static variable.
Global & static variable get stored in code segement it nither heap nor stack.
Thank You
Sethuraman.K
|
|
|
|
|
Hai all,
when i compile my program i am getting Debug Assertion Failure Message. If i click ignore the program is working fine. in my application i am calling a dialog from another dialog. Can Any one tell me what is the problem & how i can rectify this problem
Thanks in Advance
|
|
|
|
|
No one can help you unless you provide more information. Causes of assertions are numerous and varied.
Steve
|
|
|
|
|
BOOL Dialogfinal::OnInitDialog()
{
HIMAGELIST hList = ImageList_Create(16,16, ILC_COLOR8 |ILC_MASK , 8, 1);
hList = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 8, 1);
m_cImageListSmall.Attach(hList);
CFinalDlg* m_final= (CFinalDlg*)GetParent();
CBitmap cBmp;
cBmp.LoadBitmap(IDB_BITMAP1);
m_cImageListSmall.Add(&cBmp, RGB(255,0, 255));
OnCreate();
return true;
}
void Dialogfinal::OnCreate()
{
int r=0;
CFinalDlg* m_final= (CFinalDlg*)GetParent();
m_final->k[m_final->f]=t;
//Here It is Showing Debug failure UpdateData(); m_list.SetImageList(&m_cImageListSmall, LVSIL_SMALL);
m_list.DeleteAllItems();
LVITEM lvi;
CString strItem;
for (int i = 0; i<m_final->ii; i++)
{
// Insert the first item
lvi.mask = LVIF_IMAGE | LVIF_TEXT;
strItem.Format(_T(m_final->s[i]), i);
lvi.iItem = i;
lvi.iSubItem = 0;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
if(i>2)
{
//m_final->f--;
lvi.iImage = m_final->k[r];
// m_final->f++;
r++;
}
else
lvi.iImage=i;
m_list.InsertItem(&lvi);
// Set subitem 1
strItem.Format(_T("%d"), 10*i);
lvi.iSubItem =1;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_list.SetItem(&lvi);
}
// if(m_final->ii>3)
// GraphMenu.CreateMenu();
UpdateData();
}
if i am removing the update data(), no error is ther. but it is not displaying images
|
|
|
|
|
Show the actual ASSERT statement. Usually the problem is obvious when you can see this.
Steve
|
|
|
|
|
void AFXAPI DDV_MinMaxUInt(CDataExchange* pDX, UINT value, UINT minVal, UINT maxVal)
{
ASSERT(minVal <= maxVal);
if (value < minVal || value > maxVal)
_AfxFailMinMaxWithFormat(pDX, minVal, maxVal, _T("%I64u"),
AFX_IDP_PARSE_INT_RANGE);
}
|
|
|
|
|
I'll help Steve's RSI.
jannathali wrote: ASSERT(minVal <= maxVal);
Is this the ASSERT that is failing? If so, can you work out why?
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
It would seem minVal is greater than maxVal . How about posting a call stack? This is always helpful.
Steve
|
|
|
|
|
Will you please explain it
|
|
|
|
|
A call stack lists the function calls. For example FunctionA called FunctionB which called FunctionC which asserted. It's one of the most fundamental and essential things debuggers show you. If you don't know this I suggest you drop what you're doing until you're comfortable with the concept and know how to get your debugger to show you one.
Steve
|
|
|
|
|
Check your dialog's DoDataExchange function. It will look something like this:
void CMFCDialogDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT3, m_Val);
DDV_MinMaxUInt(pDX, m_Val, 1, 10);
}
The underlined part is of interest. You've probably got the numbers around the wrong way.
Steve
|
|
|
|
|
ClistCtrl has SortItems function that allows us to use an application defined callback function, the problem is that inside that function (MyCompareProc), lParam1 and lParam2 are always same so there is no sorting sice both represent same data.
Here is code from MSDN.
static int CALLBACK
MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
// lParamSort contains a pointer to the list view control.
// The lParam of an item is just its index.
CListCtrl* pListCtrl = (CListCtrl*) lParamSort;
CString strItem1 = pListCtrl->GetItemText(lParam1,0);
CString strItem2 = pListCtrl->GetItemText(lParam2,0);
return strcmp(strItem2, strItem1);
}
void snip_CListCtrl_SortItems()
{
// The pointer to my list view control.
CListCtrl* pmyListCtrl;
// Sort the list view items using my callback procedure.
pmyListCtrl->SortItems(MyCompareProc,(LPARAM)myListCtrl);
|
|
|
|
|
pc_dev wrote: ), lParam1 and lParam2 are always same so there is no sorting sice both represent same data.
The MSDN example given is wrong.
pc_dev wrote: static int CALLBACK
MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
// lParamSort contains a pointer to the list view control.
// The lParam of an item is just its index.
CListCtrl* pListCtrl = (CListCtrl*) lParamSort;
Here lParam1 and lParam2 are the item data for these two items. These needs to be set by using SetItemData .
Refer this[^] article by Ivor S. Sargoytchev.
Prasad
MS MVP - VC++
|
|
|
|
|
Thanks
|
|
|
|
|
Hi.
I have set the scrollbar range from 0 to 9900 to accomodate the original graph. But I have a few radio buttons which reduce the size of the graph. The problem is when I reduce the size of the graph and scroll right to the back of the graph, there is this empty space. I know the scrollbar range is smaller but how to I change this range when the radio button is clicked?
Thanks.
|
|
|
|
|
Hi,
try this:
CSize sizeTotal;
sizeTotal.cx = ????;
sizeTotal.cy = ????;
SetScrollSizes(MM_TEXT, sizeTotal);
Where the ???? put the values you need.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
but this can only be used if you are using CScrollview? Im using CFormView with a scrollbar control, used to control a picture control.
|
|
|
|
|
Ok,
I thought that would make you think a bit :P
From VC++ Help:
CScrollBar::SetScrollRange
void SetScrollRange( int nMinPos, int nMaxPos, BOOL bRedraw = TRUE );
Parameters
nMinPos: Specifies the minimum scrolling position.
nMaxPos: Specifies the maximum scrolling position.
bRedraw: Specifies whether the scroll bar should be redrawn to reflect the change. If bRedraw is TRUE, the scroll bar is redrawn; if FALSE, it is not redrawn. It is redrawn by default.
And when you check your radio button, set it another time with bRedraw TRUE to force the redraw of the scrollbar
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Dear all
my project needs to transform a flat image to 3-dimession image using vc++. i designed a single document interface already, so how to do this case, please help me, anyone has such code snippet?thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
|
I have a progress bar that I would like to update in my dialog box during a process, but when creating a progress bar, I have to supply the min & max for the range. Unfortunately I do not know what the max for the range should be. I.e. I don't want to set the max to 100, but my process finishes in 50 steps, leaving the progress bar halfway done....
To explain what this is used for, I open a text file (~1MB), and in a while loop extract the contents of the file, and processing that data....and I want to update the progress bar during this step
So my question is, is there anyway I can get the file size of the file I am opening, and figure out how many bytes I have processed so far, and set that as a percentage in the progress bar?
Any help would be greatly apperciated. Thanks!
|
|
|
|
|
You can reset the range after the control has been created.
It's not rocket surgery!
Within you lies the power for good, use it!!!
|
|
|
|
|
Use CFile obj.
Get the length of File in bytes by using
length = obj.GetLength()
progresslen = length \ 100
remaining = length - (progresslen*100)
progresslen++ //increment for remaining
set Progress Bar length to progresslen.
count = 0
progress = 0
while(count != length)
{
char pbuf[100]
UINT bytesread = obj.Read( pbuf, 100 )
//do processing for 100 bytes here
count += bytesread
progress++
ProgressBar.SetPos(progress)
}
Sameer();
|
|
|
|
|
Hello i want have 2 str str = "yes"(a word) and line = " yes i would like it yes"
and i want to test if the line contains the str (and how many times)
i mean
if ( line.GetAt(i) ==str.GetAt(1) && line.GetAt(i+1) == str.GetAt(2) && etc)
there is a way to put the for ( ) inside the if ( )
so if ( TRUE ) only when str exist in line
or anyone could suggest me a code to find how many times a CString str1 appears in a CString str2 ?
-- modified at 18:50 Thursday 17th May, 2007
|
|
|
|
|
Well, the code is wrong to start with, there are methods on the CString class to find a substring. Then you can set up a while loop that checks if you've moved past the end of the string, and keep looping until you can't find a substring.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|