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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Creating a toolbar in a console application

Creating a toolbar in a console application

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsdebugginghelpquestionannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FloatingMarc
    wrote on last edited by
    #1

    Hello, I made a dll that has a bunch of functions called from a console application. One of them creates a CFrameWnd window. Inside the function that creates my CFrameWnd, I can create a CToolBar object. However I now want the user of the dll (the creator of the console application) to be able to attach a customized CToolBar object to that window (instead of the default CToolBar object that I created during window creation inside the dll). So I thought I simply create the customized CToolBar object in the client application (console application) in the same way I did in the dll function. That however does not seem to work: in release mode the toolbar appears, but doesn't have any bitmap, in debug mode, I get debug assertion errors because of unexisting resource or instance handles. Following few lines in my console application are impossible to execute without assertion errors in debug mode: CToolBar* toolBar=new CToolBar(); toolBar->CreateEx((CFrameWnd*)dllFunctionGetFrameWnd(),TBSTYLE_FLAT,WS_CHILD|WS_VISIBLE|CBRS_SIZE_DYNAMIC|CBRS_TOP|WS_CLIPCHILDREN|WS_CLIPSIBLINGS); toolBar->LoadToolBar(IDR_TOOLBAR1); toolBar->SetWindowText("Toolbar"); toolBar->EnableDocking(CBRS_ALIGN_TOP); Anyone knows a workaround? Or can anyone propose an alternative solution to my problem?

    M 1 Reply Last reply
    0
    • F FloatingMarc

      Hello, I made a dll that has a bunch of functions called from a console application. One of them creates a CFrameWnd window. Inside the function that creates my CFrameWnd, I can create a CToolBar object. However I now want the user of the dll (the creator of the console application) to be able to attach a customized CToolBar object to that window (instead of the default CToolBar object that I created during window creation inside the dll). So I thought I simply create the customized CToolBar object in the client application (console application) in the same way I did in the dll function. That however does not seem to work: in release mode the toolbar appears, but doesn't have any bitmap, in debug mode, I get debug assertion errors because of unexisting resource or instance handles. Following few lines in my console application are impossible to execute without assertion errors in debug mode: CToolBar* toolBar=new CToolBar(); toolBar->CreateEx((CFrameWnd*)dllFunctionGetFrameWnd(),TBSTYLE_FLAT,WS_CHILD|WS_VISIBLE|CBRS_SIZE_DYNAMIC|CBRS_TOP|WS_CLIPCHILDREN|WS_CLIPSIBLINGS); toolBar->LoadToolBar(IDR_TOOLBAR1); toolBar->SetWindowText("Toolbar"); toolBar->EnableDocking(CBRS_ALIGN_TOP); Anyone knows a workaround? Or can anyone propose an alternative solution to my problem?

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      FloatingMarc wrote:

      a bunch of functions called from a console application. One of them creates a CFrameWnd window

      You need to look at the assertions and the code where they occur. You should see what's going wrong. You need to make sure you're making the right kind of DLL if you're using MFC in a DLL. All the info you need to do this can be found here: Kinds ofDLLs[^] Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

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