J want to add an icon i one of the column i my CGridCtrl. Firts i add a class: class MGrid : public CGridCtrl { ... public: CImageList m_ImageList; } In my function Init_grid: m_ImageList.Create(MAKEINTRESOURCE(IDB_IMAGES), 16, 1, RGB(255,255,255)); SetImageList(&m_ImageList); (IDB_IMAGES is a smallicon.bmp file) Now I want to add an icon in 2 column of my grid: void MGrid::Draw_icon(int ARow) { int ACol = 0; int ilosc_col = GetColumnCount(); CString str = ""; GV_ITEM Item; for(ACol = 1; ACol <= ilosc_col; ACol++) { Item.row = ARow; Item.col = ACol; if(ACol == 2) { Item.mask = GVIF_TEXT; str.Format(_T("Column %d"), ACol); Item.strText = str; Item.iImage = 1; Item.mask |= (GVIF_IMAGE); SetItem(&Item); } } What I see is a string "Column 1" (..n) but there is no image in the column. Can you help me? Regards mwgomez Poland
gomez_a
Posts
-
MFC Grid Control - how to add an icon -
How to set the Default Main WW PageHow can I set the default WWW page from my C++ programm? (When I am starting Internet Explorer, there is a Start WWW page). Regards mwgomez Poland
-
How to display CStaticThank you for yuour help, I must find the reason... Regards mwgomez
-
How to display CStaticI think there is steel something wrong. Please look at my source code. My dialog window is MOkno.h public: CStatic lblRecno; // for displaying recno CButton btnStart; // button Start int iLicznik; // increment variable CString newTxt; // new value of the text = iLicznik as a Text MOkno.cpp: BOOL MOkno::OnInitDialog() { CDialog::OnInitDialog(); // TODO: SetTimer(ID_TIMER1, 1000, NULL); // my Timer is running every 1 s return TRUE; } HBRUSH MOkno::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr; if(nCtlColor == CTLCOLOR_STATIC ) { pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(clBlue); hbr = (HBRUSH) GetStockObject( NULL_BRUSH ); } else { hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); } return hbr; } void MOkno::OnClose() { KillTimer(ID_TIMER1); CDialog::OnClose(); } On the dialog window tehre is a Start button. When user click on the button: void MOkno::OnBnClickedButtonStart() { iLicznik = 0; newTxt = ""; // suppose: It is a database, and I am reading records // and display the current recno number for(iLicznik = 1; iLicznik <= 1000; iLicznik++) { newTxt.Format("%d", iLicznik); } } void MOkno::OnTimer(UINT nIDEvent) { CDialog::OnTimer(nIDEvent); lblRecno.SetWindowText(newTxt); } Regards mwgomez
-
How to display CStaticNo it doesn't work. Please try it. I don't create CStatic it my sorce code, it is on the dialog window. I am setting the new Value by lblRecno.SetWindowText(...) I am setting the CStatic colour by OnCtlColor(...) and the TIMER void CDemoDlg::OnTimer(UINT nIDEvent) { lblLP.Invalidate(); CDialog::OnTimer(nIDEvent); } Regards mwgomez
-
How to display CStaticI have an MFC application (VS 2003 Std). There is a dialog window with CStaticText. For example: CStatic lblRecno; I want to change the colour of the CStaticText. I am using the OnCtlColor function: HBRUSH DlgBackup::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = NULL; /* if(pWnd->GetDlgCtrlID() == IDC_STATIC_LP) or */ if( nCtlColor == CTLCOLOR_STATIC ) { pDC->SetTextColor(clBlack); pDC->SetBkMode(TRANSPARENT); hbr = (HBRUSH) GetStockObject( NULL_BRUSH ); } else { hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); } return hbr; } To this place is OK. Now I am changeing the lblRecno value in the while loop: int lp = 0; CString newTxt = ""; while(...) { ++lp; bewTxt.Format("%d", lp); lblRecno.SetWindowText(newTxt); } But the new value lblRecno is displaying in the place of the previous value, an so on. I think I should to use the WM_ERASEBKGND, but I don't know how to do it. Can you help me. Regards mwgomez Poland
-
How to make the XP style menu useing "GuiToolkit MFC Extension" library?Of course the examples from GuiLib are running propperly. Regards mwgomez Poland
-
How to make the XP style menu useing "GuiToolkit MFC Extension" library?I want to ask about some help with: "GuiToolkit MFC Extension" http://www.codeproject.com/library/guitoolkit.asp I am writeing the MFC application (VS2003 Std - I am not useing the document-view architecture!). I do some practice with the GuiToolkit library. I can create a button or combobox. But I can not to make XP Style menu. I see this examples in folders: CGuiAccess or CGuiTabbedDemo, but it shows me in the old way. Regards mwgomez Poland
-
How to copy from CBitmap to CBitmapSuppose we have a class: class CBitmapViewer : public CWnd { ... public: CBitmap m_Bitmap; // the BMP is loaded here CRect R; // the whole window size public: virtual BOOL Create(CWnd* pParentWnd, const RECT& rect, UINT nID, DWORD dwStyle = WS_VISIBLE); BOOL SetBitmap(UINT nIDResource); }; I am creating the picture 1: CRect RPicture1(10, 10, 200, 200); mPicture1 = new CBitmapViewer(); mPicture1->Create(this, RPicture1, ID_OBRAZEK); mPicture1->SetBitmap(IDB_BITMAP_CHILD); I am creating the picture 2: CRect RPicture2(10, 220, 200, 410); mPicture2 = new CBitmapViewer(); mPicture2->Create(this, RPicture2, ID_OBRAZEK); mPicture2->SetBitmap(IDB_BITMAP_CHILD); There are two picture on the screen. Now the user can mark the part of the first window. This coorinates are placed in CRect Rf. Now, I am cutting down a part of the picture one - using the Rf coordinates: int mWidth = Rf.Width(); int mHeight = Rf.Height(); CBitmap bmp_part; bmp_part.CreateBitmap(mWidth, mHeight, 1, 24, NULL); // get the bitmap size BITMAP bitmap_size; bmp_part.GetObject(sizeof(BITMAP), &bitmap_size); // get a bitmap's part from Picture1 and place them into the bmp_part unsigned char *pData2 = new unsigned char[bitmap_size.bmHeight * bitmap_size.bmWidthBytes]; mPicture1->m_Bitmap.GetBitmapBits(bitmap_size.bmHeight * bitmap_size.bmWidthBytes, pData2); bmp_part.SetBitmapBits(bitmap_size.bmHeight * bitmap_size.bmWidthBytes, pData2); delete[] pData2; /* when I have a part of the Picture1 in the bmp_part a want to replace a Picture2 with bmp_part. */ For example using: mPicture2.Assign(&bmp_part); or I can to create the new object: mNewBitmap = new CBitmapViewer(); mNewBitmap->Create(this, R3, ID_OBRAZEK3); // CRect R3 - where the window is placed mNewBitmap->AssignBitmap(&bmp_part); From this moment I want some help, becouse I don't know how to do it Regards
-
How to copy from CBitmap to CBitmapI wrote a class in MFC (MyClass : public CWnd), in this class I have a field CBitmap mBitmap; // not a pointer I set the bitmap using method: SetBitmap(UINT nIDResource) { return m_Bitmap.LoadBitmap(nIDResource); } But now I want to set the bitmap using: SetBitmap(CBitmap *pBitmap); I don't know how to assign (change?) CBitmap *pBitmap to CBitmap mBitmap. This is only a practice, but I want to understand it. Regards
-
How to copy from CBitmap to CBitmapPlease, give me a suggest: How can I get a HBITMAP, when I have only CBitmap bmp3? I found an example: HBITMAP hBitmap = (HBITMAP) ::LoadImage (NULL, lpszPathName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); But, my bmp3 is not from a file. Regards mwgomez
-
How to copy from CBitmap to CBitmapI mean the MFC library and the CBitmap class (Visual Studio). regards mwgomez
-
How to copy from CBitmap to CBitmapI have two objects: CBitmap bmp1, CBitmap bmp2. There is a sample picture in the bmp1 and the same picture in the bmp2. Now, I get a copy of the part bmp1 and put it to the CBitmap bmp3. But I don't want to create another CBitmap object. I want release bmp2 interior and put there the new part of the picture wchich is in the bmp3. How can I do it. I can't do bmp2 = bmp3, there is no function like: bmp2.Assign(bmp3). What can I do? Regards mwgomez Poland
-
How to hide the dialog CLOSE iconYes, I know, thank you, but I want to know how to do it in the code source. Regards
-
How to hide the dialog CLOSE iconJ have an application in MFC. There is one dialog window. I want to hide the icon "close" which is inthe right upper corner of the window. What I have to do in my programm? Regards
-
Waiting for the thread end(VS 2005 MFC) I have a list of 5 threads, for example: struct T_PARAMS { HWND hWnd; // a handle to dialog window, using in thread }; int thread_count = 5; // I have 5 threads CWinThread *pThread; // pointer to thread CList mList; // list of the pointers to threads int lp = 0; // First I create 5 stopped threads: for(lp = 0; lp < thread_count; lp++) { params = new T_PARAMS(); params->hWnd = m_hWnd; pThread = AfxBeginThread(ThreadFunc, params, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); pThread->m_bAutoDelete = true; mList.AddTail(pThread); } Now, when I have a list of pointers to threads, I want run threads, but I want to do it in this way: run first thread (mList[0]), wait so long how the first thread is working, next run second thread (mList[1]) and so on. For example: POSITION pos; CWinThread *wsk = NULL; pos = mList.GetHeadPosition(); for(lp = 0; lp < thread_count; lp++) { wsk = (CWinThread *) mList.GetNext(pos); wsk->ResumeThread(); // [*] now wait until thread is working - how to do it? } My threads are working properly, I use one semaphor to allow works only 1 thread at once, but I don't know how can I do - in line [*], that programm will wait after wsk->ResumeThread() until this thread is finished his work? Regards mwgomez Poland
-
How to compile "Express OLE DB Library" under VS2003 StdI wanted to use the "Express OLE DB Library" (http://www.codeproject.com/database/expressodl.asp?df=100&tid=837433&forumid=3215&noise=5&exp=1&mpp=50&select=1293756) in my Visual Studio 2003 Standard (with MFC) application. But when i compile the first programm i have an erros: Compiling... stdafx.cpp d:\AAA\SPR\SPR\Include\SypODLCommand.h(27) : error C3203: 'CRowset' : class template invalid as template argument for template parameter 'TRowset', expected a real type d:\AAA\SPR\SPR\Include\SypODLRecordBase.h(53) : error C3200: 'int' : invalid template argument for template parameter 'TRowset', expected a class template d:\AAA\SPR\SPR\Include\SypODLCommand.h(29) : see reference to class template instantiation 'CSypODLRecordBase' being compiled with [ TAccessor=CDynamicParameterAccessorEx ] d:\AAA\SPR\SPR\Include\SypODLRecordset.h(25) : error C3203: 'CRowset' : class template invalid as template argument for template parameter 'TRowset', expected a real type d:\AAA\SPR\SPR\Include\SypODLRecordBase.h(53) : error C3200: 'int' : invalid template argument for template parameter 'TRowset', expected a class template d:\AAA\SPR\SPR\Include\SypODLRecordset.h(27) : see reference to class template instantiation 'CSypODLRecordBase' being compiled with [ TAccessor=CSypODLDynAccessor ] d:\AAA\SPR\SPR\SypOLEDBLib.rc(3) : fatal error C1083: Cannot open include file: 'SypODLResource.h': No such file or directory Build log was saved at "file://d:\Aaa\Spr\Spr\Debug\BuildLog.htm" SPR - 5 error(s), 0 warning(s) Can you help me? regards mwgomez
-
SetWindowPosIt is my code: // CSheet *sheet: class CSheet : public CPropertySheet sheet = new CSheet("Sheet"); // CDlg1 and CDlg2 properties: // style = child // border = Thin // Disabled = TRUE // //CDlg1 *pg1: class CDlg1 : public CPropertyPage pg1 = new CDlg1(); //CDlg2 *pg2: class CDlg2 : public CPropertyPage pg2 = new CDlg2(); sheet->AddPage(pg1); sheet->AddPage(pg2); sheet->Create(this, WS_CHILD | WS_VISIBLE, 0); sheet->SetWindowPos(&CWnd::wndTopMost, 12, 12, 578, 578, SWP_NOZORDER); sheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT, SWP_NOZORDER); sheet->ModifyStyleEx(0, WS_TABSTOP, SWP_NOACTIVATE); But it still desn't work. Have I any mistake? I thought - it is simple. I have an example from the book: "Visual C++ 6 Bible". (: Regards mwgomez
-
SetWindowPosI was based on the book: "Visual C++ Bible" Richard C.Leinecker, Tom Archer. There are samples how to create instance of the classes CPropertyPage, CPropertySheet. There is no associating with a Control and it works. But there is also a sample - how to create this classes in existing Dialog. I wrote it in my sample - and there is no right effect :) (I think it will be a little problem, but I am interesting in solve it). Regards mwgomez
-
SetWindowPosI have the same effect like before... Regards mwgomez