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
D

DLChambers

@DLChambers
About
Posts
12
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Track traffic sources using PHP get?
    D DLChambers

    You could use a session cookie then retrieve the value from $_COOKIE as they move thru the site.

    Linux, Apache, MySQL, PHP php com sales tutorial question

  • Customization of defaul buttons provided in PropertyPages
    D DLChambers

    In order to show all 3 of Back, Next, and Finish, you gotta move the buttons. Here's the Microsoft Knowledgebase page with sample code: http://support.microsoft.com/kb/q143210/[^]

    C / C++ / MFC tutorial question

  • HWND that *sent* a MSG?
    D DLChambers

    It's a registered message, sent between associated apps. I want the receiving app to be able to display (in a list) the name of the app that sent the msg. I could pass the sender's HWND in the wParam or lParam, but I'm extending an existing app that already uses W and L, so I'm plumb out of args and trying to cook up a workaround :)

    C / C++ / MFC question

  • Check if is folder or file function?
    D DLChambers

    Here's a Win95 :) compatible way of doing it:

    // Get full attributes
    DWORD dwAttrib = GetFileAttributes(psPath);
    // Convert non-existance code to a value that will fail the bit-test
    if(0xFFFFFFFF == dwAttrib)
    dwAttrib = 0;
    // Does it exist, and is it a dir?
    if(0 != (dwAttrib&FILE_ATTRIBUTE_DIRECTORY))
    // It's a dir!

    C / C++ / MFC question

  • Making a file not accessible by other applications
    D DLChambers
      HANDLE hFile = CreateFile(   
                     psFile,
                     GENERIC\_READ | GENERIC\_WRITE,
                     0,   // No sharing
                     NULL,
                     OPEN\_EXISTING,
                     FILE\_ATTRIBUTE\_NORMAL,
                     NULL);
      DWORD dwErr = GetLastError();
      // NOTE: Error 5 likely indicates file is marked read-only
    

    ...

      CloseHandle(hFile); // Unlock it
    
    C / C++ / MFC question

  • About Invoke Helper
    D DLChambers

    What's your context? The docs say that InvokeHelper is part of the COleDispatchDriver and CWnd classes, thus when you call InvokeHelper() you're really calling ::InvokeHelper(), which doesn't exist in the global namespace.

    C / C++ / MFC help question

  • A problem with loops
    D DLChambers

    Actually, it should be written thus:

    if (-1 == Channel)

    so if you mistakenly use = instead of == the compiler will puke. If you get in the habit of putting the constant on the left side of the equation it'll save you many headaches.

    C / C++ / MFC database help question

  • Abstract Class, Socket Programming, JPEG in VC6
    D DLChambers

    You can use OleLoadPicture(). The following code two-steps it - loads the JPG into a HBITMAP then draws the HBITMAP If you just wanted load & draw it w/o the intermediate BMP you could call pPic->Render() into the dialog's DC.

    #include <Ole2.h>
    #include <olectl.h>
    #define HIMETRIC_INCH 2540
    HBITMAP LoadJpgFile(LPCTSTR filename)
    {
    HBITMAP hBmp = NULL;

    if(filename && *filename)
    {
    HANDLE hFile = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
    if(hFile)
    {
    DWORD dwFileSize = GetFileSize(hFile, NULL);
    HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
    if(hGlobal)
    {
    LPVOID pvData = GlobalLock(hGlobal);
    if(pvData)
    {
    DWORD dwBytesRead = 0;
    BOOL bRead = ReadFile(hFile, pvData, dwFileSize, &dwBytesRead, NULL);
    GlobalUnlock(hGlobal);

          if(bRead && (dwBytesRead==dwFileSize))
          {
            LPSTREAM pstm = NULL;
            HRESULT hr = ::CreateStreamOnHGlobal(hGlobal, TRUE, &pstm);
            if(pstm)
            {
              LPPICTURE pPic = NULL;
              hr = ::OleLoadPicture(pstm, dwFileSize, FALSE, IID\_IPicture, (LPVOID\*)&pPic);
              if(pPic)
              {
                // Retrieve logical dimensions
                long lWidth=0, lHeight=0;
                pPic->get\_Width(&lWidth);
                pPic->get\_Height(&lHeight);
    
                HDC hMemDC = CreateCompatibleDC(NULL);
                if(hMemDC)
                {
                  // Map logical dimensions to physical device
                  int nWidth = MulDiv(lWidth, GetDeviceCaps(hMemDC, LOGPIXELSX), HIMETRIC\_INCH);
                  int nHeight = MulDiv(lHeight, GetDeviceCaps(hMemDC, LOGPIXELSY), HIMETRIC\_INCH);
                  if((nWidth>=0) && (nHeight>=0))
                  {
                    HDC dcScreen = GetDC(NULL);
                    if(dcScreen)
                    {
                      HBITMAP hJpgBmp = ::CreateCompatibleBitmap(dcScreen, nWidth, nHeight);
                      if(hJpgBmp)
                      {
                        HBITMAP hPrevBmp = (HBITMAP)::SelectObject(hMemDC, hJpgBmp);
    
                        RECT rect = {0,0, nWidth,nHeight};
                        hr = pPic->Render(hMemDC, 0, 0, nWidth, nHeight, 0, lHeight, lWidth, -lHeight, &rect);
    
                        ::SelectObject(hMemDC, hPrevBmp);
    
                        if(SUCCEEDED(hr))
                          hBmp
    
    C / C++ / MFC question sysadmin tutorial

  • Problem Putting Dialog on top
    D DLChambers

    Have you tried modeless dialogs?

    C / C++ / MFC help

  • Problem about ListBox item
    D DLChambers

    In the standard listbox rendering, Focus typically draws a dashed rect around the "current" item and Selected shows the item in color. The difference is useful if you want to e.g. keep the Selected item highlighted when the listbox is not focused. Usually only the affected items are redrawn. For example, if you have item 1 selected and click on item 2, you'd get draw messages for item 1 (with the selected flag cleared) and item 2 (with the selected flag set), but no draw msgs for items 0 or 3. If oyu *scroll* the listbox you'll get draw messages for all visible (either partially or fully) items, but not for those items whose rects fall outside (above/below) the window's client area.

    C / C++ / MFC question help

  • Storing files in a dll, or somewhere like that...
    D DLChambers

    You could indeed store all those the files in a dll and extract them either as-needed or extract them all upon app startup to a temp dir then delete the temp dir on app exit. The typical way to store data (eg: a file) in a dll is to put it in the dll's resource table.

    C / C++ / MFC game-dev

  • HWND that *sent* a MSG?
    D DLChambers

    When my app rx'es a message, it gets it in the form of a MSG struct. That MSG contains the HWND that is to receive the message (i.e. my wnd). Is there any way to find the main HWND of the process that sent the message?

    C / C++ / MFC question
  • Login

  • Don't have an account? Register

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