|
Hi,
after having some problems with a self-drawn dialog to derive the CPrintDialog I have successfully sent the document to the printer. The problem is that I can only print 1 page, although the pInfo->GetMaxPage () returns the correct value it should print (from 1 to 9 depending on some things).
What should I check? the pInfo structure is correct (I have check it in debugger and with AfxMessageBox ()) but it doesn't print right yet.
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?
|
|
|
|
|
Hi,
2 minutes after posting the message I have solved it. I didn't set nFromPage and nToPage in pInfo->m_pPD->m_pd. (device) so...
thanks anyways
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?
|
|
|
|
|
I have few doubts about meomory allocations in program.
1. Which variables are allocated in stack and which are in heap.
2. How can the scope of the global and static variables is through out the application.
3. Why the varibles in stack cannot have program scope while the variables in the heap can have?
Can you please give me a link or two where i can get the information on memory allocation.
Thank you.
KIRAN PINJARLA
|
|
|
|
|
At first you should probably begin with reading about the stack[^] and the heap[^].
Regarding your questions:
1. Unless you allocate memory from the heap with calls like new , malloc(...) or similar and assign the returned value to a pointer variable, your data will be allocated on the stack.
In code the difference would look like this:
int foo()
{
int nValueOnStack;
int pnValueOnHeap = new int;
....
delete pnValueOnHeap;
}
2. I don't understand your question. It doesn't validate to a full sentence.
3. I'm not really sure what you mean. But I think you will get an answer when you read how the stack works in the link above.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
1. Unless you allocate memory from the heap with calls like new, malloc(...) or similar and assign the returned value to a pointer variable, your data will be allocated on the stack.
And what about global variables? If not created in the heap, they are not in the stack too but in the global data segment.
--
=====
Arman
|
|
|
|
|
Arman Z. Sahakyan wrote: And what about global variables?
I chose to omit that in order to not confuse the OP since he asked about the difference between the stack and the heap.
As always it's difficult to give a relatively short answer matching the OP's knowledge and experience. In my opinion it's sometimes better to leave details out for clarity reasons, but unfortunately it's not a bullet proof concept.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
As already advised, you'd rather learn some tutorials on memory artchitecture. They are many in the web.
1. Which variables are allocated in stack and which are in heap.
Those that
All new-ed (or malloc-ed) variables are in the heap.
Other function scope variables are in the stack.
Globals are in the global data segment [if not created by new].
2. How can the scope of the global and static variables is through out the application.
Though not a clear question...
This needs a detailed explaination. Read some tutorials please.
3. Why the varibles in stack cannot have program scope while the variables in the heap can have?
Because the in-stack variables are managed by the stack itself and each time a function returns, its part [top] of the stack is removed and thus destroying all the variables inside that fuction scope.
--
=====
Arman
|
|
|
|
|
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?
|
|
|
|