Is it a LIFO pattern? In this case std::stack[^] is your answer
chaau
Posts
-
An algorithm question -
Can someone (briefly) explain ON_UPDATE_COMMAND_UI?If the logic that decides if the buttons should be enabled or disabled is too complicated it is advised (do not ask me to find who advised it, I just remember it somehow) that you do not use this method. You could always use CToolBarCtrl::EnableButton() for this and control it from within other parts of the program
-
VC++ Crashing?Try to run in Windows 2000 compatibility mode. First thing that comes to mind
-
How to conditional call a libraryAs an alternative, you could use delay load dll. In this case you do not need to change the code you have already written (related to statically linking to the library), all you need to do is just do not call chunk of codes related to magnification at all. Saves you a lot of annoying LoadLibrary/GetProcAddress calls. However, it looks like you have already implemented it. So, just learn about this, so that you could use in future
-
CView::OnDraw - related questionTo force the window to redraw (any window, not only view) you need to call CWnd::Invalidate()[^] method. Calling it will trigger all the drawing routines
-
How to Restart My Mfc ApplicationI think Restart Manager[^] is your answer. If you are building it with the latest MFC (the one with a feature pack), then it is built into the MFC Application Wizard[^]
-
C++: CreateProcess() launching child applications with UAC dialog for onceI think it is nothing to do with how you call CreateProcess. If your main application Setup.exe is launched in elevated mode, all processes lunched by this application will be launched in elevated mode. In order to have an elevated prompt for your Setup.exe, you need to create manifest. This simple manifest will trigger the UAC prompt for your application:
-
DialogBox fail in XPTry to set MinimumRequiredVersion to 5.00
-
DialogBox fail in XPIt is most likely the manifest. When I converted my projects to VS2010, it changed all my manifests to use urn:schemas-microsoft-com:asm.v2 in this line:
Awesome
Also, please check if you still using the manifest loaded via RT_MANIFEST resource. You need to delete this from resource and use the project settings. VS2010 has a habit of assigning RT_MANIFEST to 2, making the program unusable under XP. And of cause you need to check this linker option: MinimumRequiredVersion. It should be 5.00.
-
Why new Image failed?replace the first line with this:
Image* m_pImage = NULL;
Otherwise, m_pImage is not NULL, and you are trying to delete uninitialised pointer, leadding to memory corruption
-
Why the CTreeCtrl disable[solved]At least show us the code you use to create the Tree Control
-
CHtmlViewCall Navigate2("about.blank", 0, "_self") before GetHtmlDocument()
-
How to Resize Dialogbar? -
Drawing speedYou need to create DIB (I think you have already already created it based on the code), then you need to copy the bitmap bits to the DIB's buffer using this code:
HBITMAP hOldBitmap = NULL; if (m\_hBitmap == NULL) { m\_hBitmap = CreateDIBSection(hDC, (BITMAPINFO\*)m\_hDib, DIB\_RGB\_COLORS, &m\_lpBits, NULL, 0); if (m\_hBitmap == NULL) return; if (m\_lpBits == NULL) { ::DeleteObject(m\_hBitmap); m\_hBitmap = NULL; return; } // if } // if memcpy(m\_lpBits, ((LPBYTE)m\_hDib + \*(LPDWORD)m\_hDib + GetPaletteSize()), m\_bi.biSizeImage); if (m\_hMemDC == NULL) { m\_hMemDC = CreateCompatibleDC(hDC); if (m\_hMemDC == NULL) return; } // if hOldBitmap = (HBITMAP)SelectObject(m\_hMemDC, m\_hBitmap); BitBlt(hDC, dwX, dwY, m\_bi.biWidth, m\_bi.biHeight, m\_hMemDC, 0, 0, SRCCOPY); SelectObject(m\_hMemDC, hOldBitmap);
The main part here is the memcpy. I have copied it from my program. If you can't understand what the "m_" variables are, let me know and I will explain
-
CFileDialog is not refreshingI think in this case you should pass NULL. Please note that you need to pass only extension, e.g. for Excel files you would pass _T("xls"). For all files, pass NULL in place of szMask
-
CFileDialog is not refreshingWhat value are you passing in szMask?
-
Drawing speedThe problem is with this line:
pDoc->GetDib()->Draw(&MemDC, CPoint(0,0), sizeLog);
You need to replace it with another BitBlt that will copy stuff to MemDC
-
how do i copy a CImage DIB to clipboardIt fails because the memory allocated by GlobalAlloc is not enough. See, how you use sizeof(BITMAPINFO) + w * h * 3 value to allocate memory, and then you are trying to calculate the m_dwSizeImage value, which is much greater then requested. You have got two options: Either move this chunk of code after you have calculated the image size, so that your code becomes:
DWORD dwBytes = ((DWORD) w \* Bpp) / 32; if(((DWORD) w \* Bpp) % 32) { dwBytes++; } dwBytes \*= 4; unsigned long m\_dwSizeImage = dwBytes \* h; // no compression void\* pBits = tmpImage.GetBits(); HANDLE hData = ::GlobalAlloc (GMEM\_MOVEABLE, sizeof(BITMAPINFO) + m\_dwSizeImage); LPVOID pData = (LPVOID) ::GlobalLock (hData); LPBYTE p\_imagebits; p\_imagebits = (LPBYTE)pData + sizeof(BITMAPINFO); memcpy(pData,&bmInfo,sizeof(BITMAPINFO)); memcpy (p\_imagebits, pBits, m\_dwSizeImage);
Or, just use a solution[^] from Codeguru BTW, it looks like you have calculated the m_dwImageSize incorrectly anyway
-
Linker ErrorYou need to add a cpp file or a lib file to your project depending on what you've got. If you have FileParser.cpp file (most likely this is the case) do the following: In the Solution Explorer right click on the project and Select Add->Existing Item. Locate your FileParser.cpp and select it. If you are given a lib file together with the FileParser.h you need to add it via the Project properties. In the Solution Explorer right click on your project and select Properties. Go to Linker options -> Input. In the Additional dependencies field type the name of your lib file, e.g. FileParser.lib.
-
file is getting deletedMake sure you call ::CloseHandle(temp_file) after you have done working with it