Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
C

csc

@csc
About
Posts
22
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to convert RTF to plain text ?
    C csc

    Hello to all, i need to read a RTF file via iostream and convert it internally into plain text. The plain text should be searched for some keywords ... and the text between these keywords should be stored into an other (different) file. The problem is not to read the RTF via iostream. The problem is to skip all these formatting instructions of the RTF, because i need only the plain text. Solving that, i need some code snippet ... but i haven't found something like that. Additionally, the code should not use COM, DCOM, Automation of MS Word or somthing like that. Just a peace of C++ code. Anybody out there ... having an idea how-to or look-where ??? Thank's for any idea.

    C / C++ / MFC c++ com testing tools help

  • Problem with CBitmapButton
    C csc

    I've made a test with your code (using MSVC++ 6.0) : class CMyDialog : public CDialog { : // somewhere CBitmapButton m_Btn1; : } BOOL CMyDialog::OnInitDialog() { CDialog::OnInitDialog(); : m_Btn1.Create("",WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,CRect(0,10,30,50),this,12345); m_Btn1.LoadBitmaps(IDB_BITMAP_TEST1,IDB_BITMAP_TEST2); : return TRUE; } ... and it work's fine. Only thing is, that the button's coords a relative to the client area of the dialog ... means the button with CRect(0,10,30,50) appears in the upper left corner of the dialog. Are you sure that it is not shown ? Or is it hidden by an other control / item ? :confused:

    C / C++ / MFC help

  • Clip Region of CDC
    C csc

    Try this .. // get current clipping boundary RECT rect; pDC->GetClipBox( &rect ); // Selects the current clipping region for other dc CRgn rgn; rgn.CreateRectRgnIndirect( &rect ); m_DC.SelectClipRgn( &rgn ); ... hope it helps

    C / C++ / MFC tutorial question

  • Is there any CInt function - VB in c++?
    C csc

    Math.round public static int round( float a ) Returns the value of the argument rounded to the nearest int value. -------------------------- just do it like that : #include : double MyDouble = 2345.5678 // MyDouble is a Double. int MyInt = ROUND(MyDouble) // MyInt contains 2346. : double MyDouble = 2345.4678 // MyDouble is a Double. int MyInt = ROUND(MyDouble) // MyInt contains 2345.

    C / C++ / MFC c++ question

  • how to get long file name (instead of old 8.3 notation)
    C csc

    Is working ... thank's a lot :-D

    C / C++ / MFC tutorial question

  • how to get long file name (instead of old 8.3 notation)
    C csc

    i'm using this code snippet to create a temp file name : CString CUtil::CreateTempFileName( void ) { CString cs = ""; TCHAR szTempName[_MAX_PATH]; TCHAR szPath[_MAX_PATH]; if(GetTempPath(sizeof(szPath), szPath) != 0) { if(GetTempFileName(szPath, _T("csc"), 0, szTempName) != 0) { cs = szTempName; } } return( cs ); } Its results in something like : c:\DOKUME~1\USERKE~1\LOKALE~1\Temp\csc14.tmp Anybody with an idea how to get the (real) long file name instead of this old 8.3 notation ? Thank's for any hint ! :)

    C / C++ / MFC tutorial question

  • Opening other application from our own application
    C csc

    Try this : CString csCommand = "C:\\WINDOWS\\system32\\mspaint.exe c:\somewhere\sample.bmp"; DoExecCommand( csCommand, TRUE ); BOOL CMyDialog::DoExecCommand( CString csCommand, BOOL bWait ) { STARTUPINFO si; ::ZeroMemory(&si, sizeof si); PROCESS_INFORMATION pi; ::ZeroMemory(&pi, sizeof pi); char* pszCmd = csCommand.GetBuffer(0); BOOL bResult = CreateProcess( NULL, // pointer to name of executable module pszCmd, // pointer to command line string NULL, // process security attributes NULL, // thread security attributes FALSE, // handle inheritance flag NORMAL_PRIORITY_CLASS, // creation flags NULL, // pointer to new environment block NULL, // pointer to current directory name &si, // pointer to STARTUPINFO &pi // pointer to PROCESS_INFORMATION ); if(bResult) { if(bWait) { DWORD dwResult = WaitForSingleObject( pi.hProcess, INFINITE ); } CloseHandle( pi.hProcess ); } return( bResult ); }

    C / C++ / MFC linux help

  • about MessageBox
    C csc

    You can make a messagebox stay on top by adding the attribute MB_SYSTEMMODAL. Short example : LPCTSTR lpszText = "my message text ...."; UINT nType = MB_OK | MB_SYSTEMMODAL; UINT nIDHelp = 0; int iResult = AfxMessageBox( lpszText, nType, nIDHelp );

    C / C++ / MFC tutorial question

  • [Newbie] A button with a bitmap
    C csc

    Hi Mark seems like the loaded bitmap resource is set free when your leaving the OnInitDialog(). Therefor the bitmap not appear. Try this hint to avoid that : create a member var for the bitmap in your Dialog class : class CMyDialog : public CDialog { : : private : CBitmap m_Bmp; }; and in the OnInitDialog : BOOL CMyDialog::OnInitDialog() { CDialog::OnInitDialog(); m_Bmp.LoadBitmap ( IDB_PLAY ); m_button.SetBitmap( m_Bmp ); return TRUE; }

    C / C++ / MFC graphics

  • How to readout dynamic CEdits in MFC?
    C csc

    Trying to give some hints : Looking at the MSDN in the CEdit description of GetLine : int GetLine( int nIndex, LPTSTR lpszBuffer ) nIndex : Specifies the line number to retrieve from a multiple-line edit control. Line numbers are zero-based; a value of 0 specifies the first line. This parameter is ignored by a single-line edit control So do you have a single or multiline edit control ? And if its a multiline edit .... ever tried to use GetLine( 0, ...) instead of GetLine( 1,...) ? If you only have single lines ... try to use : CString csValue = ""; CEdit* pvalue; ptr_to_main->filterMap.Lookup( i, ( CObject*& )pvalue); pvalue->GetWindowText( csValue ); I hope it helps ... a bit.:)

    C / C++ / MFC c++ tutorial question

  • Drawing on Dialog using DC
    C csc

    I'm doing that too, but it works. Even if the dialog needs a refresh / redraw. Just to show an example, which should not look very strange from your point of view : 1) Define the handlers for InitDialog and OnPaint and add a CBitmap object in the dialogs header : class CMyDialog : public CDialog { : virtual BOOL OnInitDialog(); afx_msg void OnPaint(); : CBitmap m_bmMyBitmap; : }; 2) make sure that the OnPaint:handler are in the CPP-File : BEGIN_MESSAGE_MAP(CMyDialog, CDialog) //{{AFX_MSG_MAP(CMyDialog) ON_WM_PAINT() //}}AFX_MSG_MAP END_MESSAGE_MAP() 3) Init the Bitmap object in the OnInitDialog function BOOL CMyDialog::OnInitDialog() { CDialog::OnInitDialog(); m_bmMyBitmap.LoadBitmap( IDB_MY_BITMAP ); } 4) Fill the OnPaint-Handler : void CDialogDruckauswahl::OnPaint() { CPaintDC dc(this); // device context for painting // fill dialog background with some color..... CRect crRect; GetClientRect( &crRect ); COLORREF crColor = RGB( 255,255,255 ); CBrush* pFillBrush = new CBrush( crColor ); CBrush* pOldBrush = dc.SelectObject( pFillBrush ); CPen* pNewPen = new CPen( PS_SOLID, 1, crColor ); CPen* pOldPen = dc.SelectObject( pNewPen ); dc.Rectangle( crRect ); dc.SelectObject( pOldPen ); delete pNewPen; pNewPen = NULL; dc.SelectObject( pOldBrush ); delete pFillBrush; pFillBrush = NULL; // in welchen Bereich ? DrawBitmap( &dc, crRect, &m_bmMyBitmap ); } 5) at least : define the bitmap drawing function : void CMyDialog::DrawBitmap( CDC* pDC, CRect crRect, CBitmap* pBM ) { // create a memory dc to prepare drawing via bitblt ... CDC* pmemDCBitBlt = new CDC(); pmemDCBitBlt->CreateCompatibleDC( pDC ); CBitmap* pOldBM = pmemDCBitBlt->SelectObject( pBM ); // blit the bitmap into our view using the bitblt-xor-mode pDC->BitBlt(crRect.TopLeft().x, crRect.TopLeft().y, crRect.Width(), crRect.Height(), pmemDCBitBlt, 0, 0, SRCCOPY ); // free the memory dc and the bitmap .... pmemDCBitBlt->SelectObject( pOldBM ); delete pmemDCBitBlt; pmemDCBitBlt = NULL; }

    C / C++ / MFC graphics help question

  • web cam
    C csc

    ok, got the problem .... i've downloaded that source and the needed gdiplus files are not included. So try this ... there is an other article named hints get GDI+ running here at codeproject : http://www.codeproject.com/useritems/codemaze.asp http://www.codeproject.com/useritems/CodeMaze/GDI+Files.zip The download file is about 1 MB big, but includes a complete gdi+ version (gdiplus*.* => dll, lib, headers). I have not tried to merge both projects and re-compile the exe, but if there are problems you may ask PJ Naughter directly for a hint.

    C / C++ / MFC json question

  • web cam
    C csc

    you may try this link : http://www.naughter.com/vfwgrab.htm The app was made for posting images into web, but you may use the code (or some snippets) for your own ideas. :)

    C / C++ / MFC json question

  • How to write registry?
    C csc

    Here are some code snippets, which you may use : ////////////////////////////////////////////////////// CString GetFromRegistry( CString csRegKeyString, CString csRegKeyField, CString csDefault ) { CString csResult = csDefault; CRegKey* pRK = new CRegKey(); LONG lRegOpen = pRK->Open(HKEY_LOCAL_MACHINE, csRegKeyString); if(lRegOpen == ERROR_SUCCESS) { char cValue[1000]; memset( cValue, 0, sizeof( cValue ) ); DWORD dwSize = sizeof( cValue ); LONG lRegQuery = pRK->QueryValue( &(cValue[0]), csRegKeyField, &dwSize ); if(lRegQuery == ERROR_SUCCESS) csResult = cValue; } delete pRK; pRK = NULL; return( csResult ); } ////////////////////////////////////////////////////// BOOL SetInRegistry( CString csRegKeyString, CString csRegKeyField, CString csValue ) { BOOL bResult = FALSE; CRegKey* pRK = new CRegKey(); LONG lRegSetValue = pRK->SetValue( HKEY_LOCAL_MACHINE, csRegKeyString, csValue, csRegKeyField ); if(lRegSetValue == ERROR_SUCCESS) bResult = TRUE; delete pRK; pRK = NULL; return( bResult ); } I think there are a lot of complete classes here at codeguru. Use the code above only as an example how you may do it. Best regards

    C / C++ / MFC windows-admin tutorial question

  • How can I compute the number of weeks in a year
    C csc

    How about do it like that : COleDateTime ct = COleDateTime( 2003, 12, 31, 23, 59, 59 ); int iNumWeeks = atoi( ct.Format( "%U" ) );

    C / C++ / MFC question

  • member function as callback function problem
    C csc

    Declare the callback function as static function of the class class CXFaceRecognitionDlg:: ....... { : static void callback(IplImage* image); : } and i think you should not use the & for the call, just use the static function name : cvcamSetProperty(0, CVCAM_PROP_CALLBACK, CXFaceRecognitionDlg::callback);

    C / C++ / MFC help question c++

  • How to hide a button?
    C csc

    the other question ... the ok and cancel button which are not there but working via keystrokes ... If you want to do nothing in your dialog, just override the default handlers of these keys : class CMyDialog::CDialog { . . virtual void OnOK( ) { /* do nothing*/ }; virtual void OnCancel( ) { /* do nothing*/ }; } for details look at the msdn descriptions of these cdialog members, for example OnOk : CDialog::OnOK virtual void OnOK( ); Remarks Called when the user clicks the OK button (the button with an ID of IDOK). Override this member function to perform the OK button action. If the dialog box includes automatic data validation and exchange, the default implementation of this member function validates the dialog-box data and updates the appropriate variables in your application. If you implement the OK button in a modeless dialog box, you must override the OnOK member function and call DestroyWindow from within it. Don’t call the base-class member function, because it calls EndDialog, which makes the dialog box invisible but does not destroy it.

    C / C++ / MFC question tutorial

  • How to hide a button?
    C csc

    get access to the button (or other control) inside the dialog (this is the this in the code !) if its allready exists as a member var, everythings fine ... myBnt.EnableWindow( FALSE ); myBnt.ShowWindow( SW_HIDE ); if not get its CWnd-Pointer via the controls resource id : CWnd* pBnt = this->GetDlgItem( IDC_BUTTON1 ); if(pBnt != NULL) pBnt->EnableWindow( FALSE ); if(pBnt != NULL) pBnt->ShowWindow( SW_HIDE );

    C / C++ / MFC question tutorial

  • Size of paper in MFC print preview?
    C csc

    Do it like that : CRect crPrintPaperRect = CRect( 0, 0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES) ); for details have a look at the msdn : int CDC::GetDeviceCaps( int nIndex ) - HORZSIZE Width of the physical display (in millimeters). - VERTSIZE Height of the physical display (in millimeters). - HORZRES Width of the display (in pixels). - VERTRES Height of the display (in raster lines).

    C / C++ / MFC question c++ graphics

  • How do I output the IP Address after getting computer name??
    C csc

    Hi ... you may try this code snippet .... the result should be something like 123.456.789.123 ... hope it will help you ;) struct hostent * pHost = gethostbyname(szHostName); if(pHost != NULL) { for(int i = 0; (pHost->h_addr_list[i]!= NULL); i++ ) { CString csIP = ""; for(int j = 0; j < pHost->h_length; j++ ) { if( j > 0 ) csIP += "."; CString addr = ""; addr.Format("%u", (unsigned int)((unsigned char*)pHost->h_addr_list[i])[j]); csIP += addr; } AfxMessageBox( csIP ); } }

    C / C++ / MFC question tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups