|
One solution is to use boost::bind() like this
find_if(collection.begin(), collection.end(), boost::bind(&A::test, _1, iVal));
|
|
|
|
|
basically, I'm having problems with those pests itoa and atoi.
the initial idea was to split a file into N different smaller files, each of them having their filenames sequencial (ie: 1.txt, 2.txt, ... N.txt)
what I have thought is:
[code]
int i = 1;
...
while(!inFile.eof())
{ ofstream outFile(i); //obviously, ofstream doesn't let me to do this
j=1;
while(j <= instances_per_file && !inFile.eof())
{ inFile >> s;
outFile << s << endl;
j++;
}
N++;
}
...
[/code]
currently using cygwin, but solution must be plataform/compiler independent.
any ideas how to convert int to string without itoa and sstream?
sorry if I posted on wrong place.
|
|
|
|
|
What's wrong with itoa() ? Can you use sprintf() instead?
"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
|
|
|
|
|
lockheart87 wrote: any ideas how to convert int to string without itoa and sstream?
std::stringstream is the one C++ string stream class. It is bound to be platform independent, and does exactly what you need.
itoa is its ugly little brother from the C-Library. Also standardized.
Why won't you use both? Is your assignment prohibiting that?
What are you allowed to use, if not standardized library routines?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
i subclassed CButton class and have a onmousemove in it and i need to set text on my dialog i know it can be done ive done it before but i cant remember now to save my life
void CMyButton::OnMouseMove(UINT nFlags, CPoint point) <br />
{<br />
if (!m_bOverControl)<br />
{<br />
TRACE0("Entering control\n");<br />
<br />
m_bOverControl = TRUE;<br />
Invalidate();<br />
<br />
if (GetDlgCtrlID() == IDC_STATUS_BUTTON)<br />
{<br />
}<br />
if (GetDlgCtrlID() == IDC_SEARCH_BUTTON)<br />
{<br />
MessageBox("hi");<br />
}<br />
if (GetDlgCtrlID() == IDC_OPTIONS_BUTTON)<br />
{<br />
MessageBox("low");<br />
}<br />
SetTimer(m_nTimerID, 100, NULL);<br />
} <br />
CButton::OnMouseMove(nFlags, point);<br />
}
the messagebox works.
|
|
|
|
|
Usually it's preferable to send/post a message to the parent
and let the parent set the text. This eliminates the need for the child
to have intimate knowledge of its parent.
Regardless of how you choose to implement this, eventually you'll
probably want to use SetWindowText() to set the IDC_DISPLAY_TEXT
control's text.
Also, what sets your m_bOverControl to FALSE? Is that what the timer is for?
If so, you may want to look into TrackMouseEvent() and WM_MOUSELEAVE
for a more elegant solution to tracking when the cursor leaves a window.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
ive tryed SetWindowtext()but nothing happens ive tryed ::SetWindowText() to but for some reason i cant get a HWND to my control till after its to late
|
|
|
|
|
What type of control is it?
What window is the parent of the control?
Is it the same parent as the button's parent?
If you're using MFC then you should be using an MFC object to
wrap the control - CStatic, CEdit, etc.
If you don't use an MFC control object, there's GetDlgItem() to get
a control's HWND given its ID. You need to know the controls parent to
use it, that's it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I need to print an array of 24 individual bitmap files( about 1.5 inch image each) in array of 4X6 directly to the printer on one page. I can print only one file using foll. code. Is there any way I can use a for loop or any other trick to accomplish this? Please help!
void PrintBitmap(LPCTSTR filename)
{
CPrintDialog printDlg(FALSE);
printDlg.GetDefaults();
// Or get from user:
// if (printDlg.DoModal() == IDCANCEL)
// return;
CDC dc;
if (!dc.Attach(printDlg.GetPrinterDC())) {
AfxMessageBox(_T("No printer found!")); return;
}
dc.m_bPrinting = TRUE;
DOCINFO di;
// Initialise print document details
::ZeroMemory (&di, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
di.lpszDocName = filename;
BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job
// Get the printing extents
// and store in the m_rectDraw field of a
// CPrintInfo object
CPrintInfo Info;
Info.SetMaxPage(1); // just one page
int maxw = dc.GetDeviceCaps(HORZRES);
int maxh = dc.GetDeviceCaps(VERTRES);
//Info.m_rectDraw.SetRect(0, 0, maxw, maxh);
for (UINT page = Info.GetMinPage(); page <= Info.GetMaxPage() && bPrintingOK; page++)
{
dc.StartPage(); // begin new page
Info.m_nCurPage = page;
CBitmap bitmap;
// LoadImage does the trick here, it creates a DIB section
// You can also use a resource here
// by using MAKEINTRESOURCE() ... etc.
//for (int ii=0; ii<2; ii++)
if(!bitmap.Attach(::LoadImage(
::GetModuleHandle(NULL), filename, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE))) {
AfxMessageBox(_T("Error loading bitmap!")); return;
}
BITMAP bm;
bitmap.GetBitmap(&bm);
int w = bm.bmWidth;
int h = bm.bmHeight;
// create memory device context
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap *pBmp = memDC.SelectObject(&bitmap);
memDC.SetMapMode(dc.GetMapMode());
dc.StretchBlt(0, 0, 2*w, 2*h, &memDC, 0, 0, w, h, SRCCOPY);
// clean up
memDC.SelectObject(pBmp);
bPrintingOK = (dc.EndPage() > 0); // end page
}
if (bPrintingOK)
dc.EndDoc(); // end a print job
else dc.AbortDoc(); // abort job.
}
|
|
|
|
|
ShilpaGupte wrote: Is there any way I can use a for loop or any other trick to accomplish this?
Sure - any kind of loop will do.
Separate out the code that is page related - Initialization and cleanup.
In between those, loop through the images, rendering them to the appropriate
location on the printer DC.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for replying!! I have tried using a for loop. But lemme try again. and I'll let u know.
Shilpa Potnis.
|
|
|
|
|
Does anyone know how what to set in VS2005 so that you can debug a DLL? I know what to do normally, VS2003 was fine but for some reason I cannot debug a DLL in VS2005! I have set the executable to call the DLL from and I have output the debug version of the DLL to the correct path etc,...
I have read somewhere that it is a known issue in VS2005 and you need to install sybols locally.
|
|
|
|
|
In the folder where your "debug configuration" goes there should be a .pdb(program debug database) file. Place this file into the same directory you are placing the "debug configuration" dll. Then under Debug -> Attach To Process, select what ever is using the dll file. Set your break points and let her rip.
[Insert Witty Sig Here]
|
|
|
|
|
topsort algorithm using minimal vertex...Please do show me some example as well guidance.Thank you.
|
|
|
|
|
what does your textbook say ?
|
|
|
|
|
Chris Losinger wrote: what does your textbook say ?
Wow! They have talking text books now! Man when I was in school we had to READ them.
|
|
|
|
|
No. Do your own homework.
______________________________________
Computer programmers are like umpires.
No one knows your name until you screw up.
|
|
|
|
|
Have you tried calling TopSort(array, vertex::minimal) ?
"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
|
|
|
|
|
hi all, i have a class derived from CDialogImpl<>,i want to catch the Message WM_Keydown, and identify if that key is esc then dont close the dialog.
i have managed to do that in MFC application using Pretranslate function but that function is not working in ATL class,
i have tried to override DialogProc() but this function also not called, similaraly other option like CMessage::PreTranslateMessage and but same result these function are not called.
how to get equalent of MFC's PreTranslateMessage() in this class.
Regards.
Tasleem Arif
|
|
|
|
|
What about overriding CDialogImpl::DialogProc()?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i override that function but did not worked either.
here was code i was using
static virtual LRESULT CALLBACK DialogProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);<br />
LRESULT CMiniBubbleDialog::DialogProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)<br />
{<br />
WriteEventLog1("Proc called");<br />
switch(uMsg)<br />
{<br />
case WM_MOVE:<br />
WriteEventLog1("Mouse is moved");<br />
break;<br />
case WM_LBUTTONDOWN:<br />
WriteEventLog1("Lbutton Down");<br />
}<br />
return 0;<br />
}<br />
but did not worked.
Regards.
Tasleem Arif
|
|
|
|
|
Maybe override CDialogImpl::GetDialogProc() and return a pointer to your dialog proc.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You can Override OnCancel();
Like this!.
void YourClassName::OnCancel()
{
// TODO: Add your specialized code here and/or call the base class
CDialog::OnCancel();
}
Thanks and Regards.
SANTHOSH V
|
|
|
|
|
as suggested by santosh, you can override it or comment the following code
//CDialog::OnCancel();
|
|
|
|
|
Hi, is there any simple way how to change radio-button,check box and group box TEXT COLOR?
OnCtlColor evidently doesn't work
Or some class to do it for me?
Thanx
viliam
|
|
|
|