|
No need for an array of arrays...
int (*My500x500Array)[500] = new int[500][500];
for (int ii = 0; ii < 500; ++ii)
{
for (int jj = 0; jj < 500; ++jj)
{
My500x500Array[ii][jj] = jj;
}
}
delete[] My500x500Array;
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Check the thread subject, In what way is this array dynamic ?
|
|
|
|
|
carrivick wrote: In what way is this array dynamic ?
The fact that the new and delete operators are present.
"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
|
|
|
|
|
It's created on the heap?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello, i have a toolbar with small icon buttons in. When i delete a button by sending a TB_DELETEBUTTON to it, it dosn't resize automatically. And since the buttons have a fixed size, there is an empty spot in the toobar, where i want it to automatically resize to fit the number of buttons.
How do i do this? Iv tried sending TB_AUTOSIZE to the toolbar, but nothing happens. Must i manually use TB_GETMETRICS and TB_SETMETRICS to calculate the new size of the toolbar?
Thanks
|
|
|
|
|
I am doing printing on two types of printer e.g EPSON StYLUS C82 & HP Deskjet 5700.When printing using HP,i have displayed two Text one after other with some coordinates passed to it.Text are displayed one after other with some GAP.But when i print using EPSON ,Text are displayed one after other with Larger GAP.How this problem could be soved.Example code of this is:
pDC->ExtTextOut(XCoOrdinate,YCoOrdinate+LINEGAP_Y,ETO_OPAQUE ,NULL, "Date",NULL);
XCoOrdinate+=ParamHeadingRectWidthPrint;
pDC->ExtTextOut(XCoOrdinate,YCoOrdinate,ETO_OPAQUE ,NULL, "Time",NULL);
Thanks & regards,
priyank
|
|
|
|
|
You will need to use NON DEVICE DEPENDANT UNITS. I had some problems like that printing with the same mark but different models.
I coded it in that way:
void CMyView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
CMyDoc* pDoc = GetDocument ();
ASSERT_VALID (pDoc);
pDC->SetMapMode (MM_LOMETRIC);
double dLeftOffset=200-(pDC->GetDeviceCaps(PHYSICALOFFSETX)*254.0)/pDC->GetDeviceCaps(LOGPIXELSX);
double dTopOffset=200-(pDC->GetDeviceCaps (PHYSICALOFFSETY)*254.0)/pDC->GetDeviceCaps (LOGPIXELSY);
double dRightMargin=1950-(pDC->GetDeviceCaps (PHYSICALOFFSETX)*254.0)/pDC->GetDeviceCaps(LOGPIXELSX);
double dBottomMargin=2770-(pDC->GetDeviceCaps (PHYSICALOFFSETY)*254.0)/pDC->GetDeviceCaps(LOGPIXELSY);
pInfo->m_rectDraw.left += (int) dLeftOffset;
pInfo->m_rectDraw.top += (int) dTopOffset;
pInfo->m_rectDraw.right = (int) dRightMargin;
pInfo->m_rectDraw.bottom = (int) dBottomMargin;
then to print images... I used the ::StretchDIBits (...) function, and to print text the pDC->TextOut (...) function. But using coordinates like
pInfo->m_rectDraw.left + XXX;
pInfo->m_rectDraw.top - XXX;
and so on.
Hope it helps
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?
|
|
|
|
|
Thank u for u help.I am facing with another problem in same thing.While printing font changes for different printer.I have created font using:
int nHorz = pDC->GetDeviceCaps(LOGPIXELSX);
CFont fnTimes;
int FontPrinterWeldData = (EUROPEANWELDDATAFONT*nHorz)/PIXPERINCH;//..where //PIXPERINCH=150,
//EUROPEANWELDDATAFONT=18
fnTimes.CreateFont(FontPrinterWeldData , 0, 0, 0, FW_NORMAL ,FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, FF_DONTCARE, _T("Courier New"));
I can't understand why font change for printer.
Thanks & regards,
priyank
|
|
|
|
|
I guess it is because not all printers have the same PixelsPerInch, it depends on printers, properties of actuall printing job (optimal, low quality...) and other factors
I use the font as follows:
CFont fontLabels;
fontLabels.CreatePointFont (80, "MS Sans Serif", pDC);
CFont fontInfo;
fontInfo.CreatePointFont (140, "MS Sans Serif", pDC);
From MSDN help:
BOOL CreatePointFont( int nPointSize, LPCTSTR lpszFaceName, CDC* pDC = NULL );
This function provides a simple way to create a font of a specified typeface and point size. It automatically converts the height in nPointSize to logical units using the CDC object pointed to by pDC.
When you finish with the CFont object created by the CreatePointFont function, first select the font out of the device context, then delete the CFont object.
.........
It works good for me. I have tested it with 5 different printers (in high and low quality) and a plotter without problems. I don't want to say it will never have problems, but i think is one of the best options.
The fact is to use a standard font that ALWAYS goes with windows like arial, ms sans sherif, times new roman and so on... using CreatePointFont
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?
|
|
|
|
|
Have you tried a more WYSIWYG approach? Try using the MM_ANISOTROPIC mapping mode as it makes it easier to match your view and print output using the same OnDraw code.
Here's a quick sample to plop into a new CScrollView doc/view app to see if the results are consistent on your printers. Keep in mind that it's more important to preserve aspect ratio, keeping everything proportional, and ensuring no drawing code falls outside the printable area. You will find small variances in the metric accuracy on all printers so focus more on the relative placement and you'll suffer less print anxiety.
//CDocument members...
// Header file .h
protected:
CSize m_DocSize;
// Implementation file .cpp
CSize CYourDoc::GetDocSize() const
{
return m_DocSize;
}
CYourDoc::CYourDoc()
{
// TODO: add one-time construction code here
m_DocSize=CSize(2000,2800);
}
//CScrollView members...
// Header file .h
private:
int m_nPage;
// Implementation file .cpp
CYourView::CYourView()
{
// TODO: add construction code here
SetScrollSizes(MM_TEXT,CSize(0,0)); // Set arbitrary values
m_nPage=1;
}
/***************************************
NOTE: The pInfo parameter is uncommented
****************************************/
void CYourView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* pInfo)
{
// TODO: add extra initialization before printing
pInfo->SetMaxPage(3);
}
void CYourView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
m_nPage=pInfo->m_nCurPage;
CScrollView::OnPrint(pDC, pInfo);
}
void CYourView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CScrollView::OnPrepareDC(pDC);
// TODO: Add your specialized code here and/or call the base class
// Set up the DC for the current scale factor
int nExtentX;
int nExtentY;
CSize sizeDoc;
CRect rectClient;
pDC->SetMapMode(MM_ISOTROPIC);
// Get pertinent rectangle data
GetClientRect(&rectClient);
sizeDoc=GetDocument()->GetDocSize();
sizeDoc.cy=(-sizeDoc.cy); // Y goes down as it increments
pDC->SetWindowExt(sizeDoc); // Window extent is size of document
// Calculate viewport extent
nExtentX=rectClient.Width();
nExtentY=(int)((nExtentX*sizeDoc.cy)/(sizeDoc.cx));
// What kind of device context do we have?
if (pDC->IsPrinting()==TRUE) {
pDC->SetViewportExt(pDC->GetDeviceCaps(HORZRES),-pDC->GetDeviceCaps(VERTRES));
} else {
// Context is for screen
pDC->SetViewportExt(nExtentX,nExtentY);
}
}
void CYourView::ResetScrollBars()
{
CSize sizeDoc;
CClientDC dc(this);
this->OnPrepareDC(&dc); // Update the device context
sizeDoc=GetDocument()->GetDocSize();
dc.LPtoDP(&sizeDoc); // Logical to device
this->SetScrollSizes(MM_TEXT,sizeDoc); // Update scrollbars
}
void CYourView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
ResetScrollBars();
}
void CYourView::OnDraw(CDC* pDC)
{
CTestPrintDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CSize sizeDoc=pDoc->GetDocSize();
CRect rectOutline(0,0,sizeDoc.cx,sizeDoc.cy);
rectOutline.DeflateRect(10,10); // Ensure we can see it
LOGFONT logFont={0};
memcpy(logFont.lfFaceName,"Arial",6);
logFont.lfHeight=300;
CFont font;
font.CreateFontIndirect(&logFont);
CFont* pOldFont=pDC->SelectObject(&font);
CBrush* pOldBrush=(CBrush*)pDC->SelectStockObject(NULL_BRUSH);
CString sMessage;
sMessage.Format("You can add code to center the printout later\nPage %d",m_nPage);
pDC->DrawText(sMessage,&rectOutline,DT_CENTER|DT_WORDBREAK);
pDC->Rectangle(&rectOutline);
pDC->SelectObject(pOldFont);
pDC->SelectObject(pOldBrush);
}
|
|
|
|
|
Hi
How to display url in dialog box.
|
|
|
|
|
Do u want to display a link ?
|
|
|
|
|
The same way you would any other piece of text. Most controls utilize SetWindowText() for this.
"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
|
|
|
|
|
Do you want to display a url on the dialog box or you want it has its characteristic?
|
|
|
|
|
Hi All,
I am using customize ListBox control in which I am adding JPEG images in ListBox. In this case there are 5 checkBox on dialog box and I want whenever user click on any CheckBox then imgage related to that check box will load and if user click on more than one check box then images related to that check box should be add in ListBox. I can display image in ListBox whenever user click on any checkBox it. But when he/she click on other checkBox then previous images gets disappear and new image placed at first position on listBox. So how can we solve this probelm. if any body have any solution then plz forward it.
Thanks in Advance
Atul
|
|
|
|
|
How are you responding to the LBN_SELCHANGE notification?
"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 am using the VC2005 Setup project to make the install.exe for my project. And I am using the following things for the Unistall.exe
I am using Shortcut with Following command line
Installer.msi /x GUID
GUID i m taking by right clicking on the Installer.
But the Problem is that it simply show me the dialog box about how to use the Commnad line argument with the Installer.msi
If u know what is the problem please help.
Thnx in Advance
|
|
|
|
|
well, usually (if I well remembering) I uninstall my applications simply using the /u option.
Russell
|
|
|
|
|
Hi,
I use the thing u told me but it also show me the same message.Following is the full path I am using in Shortcut.
"D:\Gaurang\installer.msi" /u
And when I use the Below code it tell me that packag doesn't exist. but the application is installed
"D:\Gaurang\installer.msi" /uninstall
-- modified at 6:17 Wednesday 12th September, 2007
|
|
|
|
|
D:\Gaurang\SetUp.exe /u or /uninstall
where D:\Gaurang contains also installer.msi
Russell
|
|
|
|
|
I tried the Same thing you told me.But still I got the Error. Error is different then previous one. It is as follows
An Error Occure attempting to install installer.exe
|
|
|
|
|
I tryed this way only on XP.
I hope that this isn't a problem related to the OS.
Elseway try on XP if the procedure is correct and then ask somewhere how solve this bug with Vista.
good luck;)
Russell
|
|
|
|
|
No I am not using vista. I am using Win2000.
I used the Following command line in Shortcut and it works.
msiexec /x "D:\Gaurang\installer.msi"
But don't know how to put this shortcut in the Setup project.
|
|
|
|
|
in my vc++ 6.0 project, i want to know the list of activex controls used.
is it possible.kindly raise your views on this point.
why i wanted this?
long ago(1.5 years) i developed one project and used some activex controls in that.
now i have opened that project in some other system and i am getting the error regarding the missing activex controls.
i can trace them back if i can know the list of activex controls i have used.
thanks in advance.
|
|
|
|
|
Open the .rc file of your project in any text editor ex notepad.
search for some key similar to "{########-####-####-####-############}" where # is 0-9 or A-Z
Open Registry using Regedit and Search this key in your registry.
If this key does not exist, then this is the com component that is missing.
You can search the component on your old machine using same technique.
|
|
|
|