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
B

Ben Aldhouse

@Ben Aldhouse
About
Posts
55
Topics
18
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • My 1990s screen saver app!
    B Ben Aldhouse

    Cheers Ravi!

    The Lounge

  • My 1990s screen saver app!
    B Ben Aldhouse

    Hopefully I'll putting an article about this up in the next couple of days. I'm quite excited about it! Communicating With A Direct2D Graphics Thread - YouTube[^]

    The Lounge

  • Heap Corruption issue
    B Ben Aldhouse

    Thanks for your reply! I don't know, to be honest. The problem was occurring when I AltF4ed or clicked on Close Window but not when I clicked on my 'Exit' button. However, it looks like it was a corrupt memory problem I had with a member variable I'd assigned to the heap and was using to pass data between threads. I've changed the communication to the following: In the sending thread:

    ControlDlg \* pParent = (ControlDlg \*) this->GetParent();
    ColourAlphaEnvelope \* s = new ColourAlphaEnvelope;
    \*s = m\_ColourEnvelope;
    pParent->PostMessage(CM\_COLOURBOUNDS, reinterpret\_cast<WPARAM>(s));
    

    and in the recieving dialog I used

    afx_msg LRESULT CRectArtDlg::OnCmColourbounds(WPARAM wParam, LPARAM lParam)
    {
    std::auto_ptr<ColourAlphaEnvelope> s(reinterpret_cast<ColourAlphaEnvelope*>(wParam));
    m_colourEnvelope = *s;
    return 0;
    }

    I bet there are dozens of better ways of doing this (not least since a quick Google reveals that auto_ptr is depracated) but I haven't had a crash and the compiler isn't telling me there is a memory leak.

    C / C++ / MFC

  • Heap Corruption issue
    B Ben Aldhouse

    I've got an application which has two dialogs, I use a deque and Direct2D in one dialog within a thread. Now, if I close the application via handling WM_CLOSE I have no problem but when I try and close it by clicking on 'Close Window' in the task bar or using Alt F4 I get a breakpoint triggered on

    if (!HeapFree(select_heap(block), 0, block))

    I know it's a long shot since I have given so little detail - but seeing as the difference seems to be in the way I close the app down I was hoping there might be a quick and easy fix for this. Yours hopefully, Ben *Update since I posted in this it the next door forum, this morning, by mistake: I still get the same error if the thread (and hence the direct2d drawing) isn't running. Perhaps it is something to do with the way I set up the dialogs.

    C / C++ / MFC

  • Heap Corruption
    B Ben Aldhouse

    Sorry about the vagueness of this... but I have to start my shift at the store in a minute... this coding business is my hobby! I've got an application which has two dialogs, I use a deque and Direct2D in one dialog within a thread. Now, if I close the application via handling WM_CLOSE I have no problem but when I try and close it by clicking on 'Close Window' in the task bar or using Alt F4 I get a breakpoint triggered on

    if (!HeapFree(select_heap(block), 0, block))

    I know it's a long shot since I have given so little detail - but seeing as the difference seems to be in the way I close the app down I was hoping there might be a quick and easy fix for this. Yours hopefully, Ben

    ATL / WTL / STL

  • How do I check to see if any running applications have unsaved documents?
    B Ben Aldhouse

    This looks interesting. May be I'll get around to having a look at what is going on with these messages eventually. It would be an interesting exercise. However, now I have seen that it isn't just short cuts to shutdown.exe that cause Windows to close down in a way that can cause unsaved work to be lost I've come to the conclusion that this is a possible oversight by Microsoft and I'll probably leave it for a while to see if they change it back themselves before I attempt to write my own fix. Oh for just a little bit more time per day to get things done...

    Windows Development question tutorial

  • How do I check to see if any running applications have unsaved documents?
    B Ben Aldhouse

    Eddy Vluggen wrote:

    Probably more a reaction to applications blocking/preventing Windows from shutting down.

    Windows not closing down is actually useful to me, though, seeing as I am often daft enough to try and close down my computer before I have saved my work!

    Windows Development question tutorial

  • How do I check to see if any running applications have unsaved documents?
    B Ben Aldhouse

    Thanks for your replies Richard and Eddy. I think I may have discovered a 'feature' of Windows 10 here. I have just done some experiments with Notepad++ v6.7.7 and Inkscape v0.91. Notepad is so advanced that an unsaved document gets saved anyway and opened up next time you open Notepad++. I think Visual Studio tends towards this level of foolproofness, too. It will give a message when you open it up asking if you would like to 'recover' unsaved files from the last session. Inkscape, however, will lose what you were working on if you haven't saved it. When I try and close Inkscape with an unsaved document it will produce a dialog asking me if really want to close it. However, when I close Windows 10 with an unsaved Inkscape document the document is lost. I think that this dialog would have caused the shutdown process to ask for user feedback in older versions of Windows. Not so in the current version of 10. Is it Windows policy now that all applications should save documents on the fly or users be more careful? Is it an oversight in Windows 10? May be it will be fixed soon and I won't have to write my little program...

    Windows Development question tutorial

  • How do I check to see if any running applications have unsaved documents?
    B Ben Aldhouse

    I thought there would be some way of centrally registering if a document is unsaved. After all, doesn't then main 'Power Off' button in Windows prompt you with an 'You have unsaved data. Are you sure you want to close down?' type message? - which suggests that this is the case for at least some applications.

    Windows Development question tutorial

  • How do I check to see if any running applications have unsaved documents?
    B Ben Aldhouse

    I have seen other people's solution to the rather small, obscured 'power off' button in Windows 10 - by making a link to shutdown.exe. Unfortunately, as far as I can see, shutdown.exe will not check to see if there are any unsaved documents and will close the computer whether data is saved or not. Also, although you can delay shutdown.exe - this, I think, is made almost completely pointless by the fact that there is no way to cancel it (that I can see). My idea is to write a small program which will call shutdown.exe after a delay but which can be cancelled. This bit, I'm pretty sure I can do. The part I have no idea how to do is to check to see if there are any unsaved documents so I can give the user the option to quit shut down. Is it possible to check to see if there are unsaved documents? How would I do this? Thanks.

    Windows Development question tutorial

  • Direct2d dilemma
    B Ben Aldhouse

    Thanks, Jochen. This did the trick.

    Windows API help c++ visual-studio com tutorial

  • Direct2d dilemma
    B Ben Aldhouse

    That was another good suggestion. That must have got left in from some old attempt to edit the string. In the end I used the

    #pragma comment( lib, "d2d1" )

    line that someone else suggested. At last I've got this thing to compile and run! Thanks again for your help.

    Windows API help c++ visual-studio com tutorial

  • Direct2d dilemma
    B Ben Aldhouse

    That looks like good advice. Sorry for pestering you with what must look silly questions to you. I really appreciate your help! I did a search for d2d1.lib and found four instances on my computer. I chose one and have tried to add it into my project dependencies under 'Linker/input/additional dependencies' but get an error

    1>LINK : fatal error LNK1104: cannot open file ',.obj'

    Here is the string I have got in that field...

    kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;dwrite.lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64\d2d1.lib;%(AdditionalDependencies),

    Is this the right place to add a library file include for the build? If so I guess it's a formatting problem or the wrong file or something... Thanks

    Windows API help c++ visual-studio com tutorial

  • Direct2d dilemma
    B Ben Aldhouse

    I've taken away the extra asterisks. Now I get a problem which produces the compiler error

    1>UsingDirect2D.obj : error LNK2019: unresolved external symbol _D2D1CreateFactory@16 referenced in function "long __cdecl D2D1CreateFactory(enum D2D1_FACTORY_TYPE,struct _GUID const &,void * *)" (?D2D1CreateFactory@@YAJW4D2D1_FACTORY_TYPE@@ABU_GUID@@PAPAX@Z)

    This is where I call D2D1CreateFactory(...)

    HRESULT DemoApp::CreateDeviceIndependentResources(){
    HRESULT hr = S_OK;

    // Create a Direct2D factory.
    hr = D2D1CreateFactory(D2D1\_FACTORY\_TYPE\_SINGLE\_THREADED, &m\_pDirect2dFactory);
    
    return hr;
    

    }

    And I do have

    #include

    at the top of the file. Cheers for any help.

    Windows API help c++ visual-studio com tutorial

  • Direct2d dilemma
    B Ben Aldhouse

    Thanks for this. I'd clearly been messing around trying to get it to work when it was probably something else.

    Windows API help c++ visual-studio com tutorial

  • Direct2d dilemma
    B Ben Aldhouse

    Good point. Bad pointer operator placement.

    Windows API help c++ visual-studio com tutorial

  • Direct2d dilemma
    B Ben Aldhouse

    I've been trying to get the example code at https://msdn.microsoft.com/en-us/library/windows/desktop/dd370994%28v=vs.85%29.aspx[^] to work for me. It's a struggle for me. One problem I think I've narrowed down is with the line

    	// Create the window.
        m\_hwnd = CreateWindow(
            L"D2DDemoApp",
            L"Direct2D Demo App",
            WS\_OVERLAPPEDWINDOW,
            CW\_USEDEFAULT,
            CW\_USEDEFAULT,
            static\_cast(ceil(640.f \* \*dpiX / 96.f)),
            static\_cast(ceil(480.f \* \*dpiY / 96.f)),
            NULL,
            NULL,
            HINST\_THISCOMPONENT,
            this
            );
    

    I think I am getting unstuck on the paramaters which call the ceil function... The compiler gives...

    c:\users\ben\dropbox\programming\direct2d\usingdirect2d\usingdirect2d\usingdirect2d\usingdirect2d.cpp(405): error C2100: illegal indirection

    Any ideas welcome! Cheers

    Windows API help c++ visual-studio com tutorial

  • Cursor from Bitmap Conundrum
    B Ben Aldhouse

    Hello. I have a cursor conundrum. I am developing a custom control and one feature I want this custom control to have is the ability to be able to rearrange its appearance by dragging and dropping one part of it to another. The way I decided I would do this would be to: 1) Convert the selected area into a bitmap 2) Use the bitmap from 1) as the cursor until the drop point is selected. 3) Redraw the control in the new arrangement. I am not worried about step 3). That should be trivial - it won't involve anything I haven't achieved already in my code concerning bitmaps or device contexts. However, I have a conundrum concerning step 2). I have achieved what I want to achieve but only if I save the bitmap to a file first then reload it as a cursor! What I am looking for here is a way of obtaining the bitmap data and converting it directly into a cursor. Clearly my problem stems from having cobbled together samples of code from various sources without properly understanding what is going on - So I call the image capuring function on clicking the mouse...

    void CScrollBarEx::OnLButtonDown(UINT inFlags, CPoint inPoint) {
    ...
    CaptureAnImage(sliderVector[m_currentSlider-1].sliderRect);
    ...
    }

    and then you can see where I have edited out the code where I try and use the HBITMAP used to subsequently make a .bmp file to make the cursor - doing this always produces a black rectangle as the cursor. However- when I save that HBITMAP to .bmp file, then reload it into memory and use that to make a cursor - it works perfectly!

    int CScrollBarEx::CaptureAnImage(RECT sliderRect)
    {
    //HDC hdcScreen;
    HDC hdcWindow;
    HDC hdcMemDC = NULL;
    HBITMAP hbmScreen = NULL;
    BITMAP bmpScreen;

    HBITMAP m\_hAndMask;
    HBITMAP m\_hXorMask;
    
    
    // Retrieve the handle to a display device context for the client 
    // area of the window. 
    //hdcScreen =  (GetDC())->GetSafeHdc();
    hdcWindow = (GetDC())->GetSafeHdc();
    
    // Create a compatible DC which is used in a BitBlt from the window DC
    hdcMemDC = CreateCompatibleDC(hdcWindow); 
    
    
    if(!hdcMemDC)
    {
       // MessageBox(hWnd, L"CreateCompatibleDC has failed",L"Failed", MB\_OK);
        goto done;
    }
    
    // Get the client area for size calculation
    RECT rcClient;
    GetClientRect(&rcClient);
    
    
    /\*
    //This is the best stretch mode
    SetStretchBltMode(hdcWindow,HALFTONE);
    
    //The source DC is the entire screen and the destination DC is the current window (
    
    C / C++ / MFC graphics performance help question

  • Sending iterator items to other functions from in a for block....
    B Ben Aldhouse

    Thanks very much for showing me how this can be done, Stefan. I have tried your method and it works perfectly. I have thought some more about what I'm trying to achieve, though, and have come to the conclusion that since the vector array has class scope and that its members don't themselves know, or need to know, whether they are the current item in the 'for' block (where I've got the iterator) - the more elegant solution would, I guess, involve just sending an (integer) identifier for the required element. Your help is very much appreciated. Your correspondence has helped my thought process a lot. Cheers, Ben

    C / C++ / MFC graphics question

  • Sending iterator items to other functions from in a for block....
    B Ben Aldhouse

    Thanks for this! I will certainly give this a go and let you know how I get on. It might not be for a few weeks, though...

    C / C++ / MFC graphics 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