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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Using MFC with windows form

Using MFC with windows form

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++comdata-structuresdebugging
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.
  • M Offline
    M Offline
    minihotto
    wrote on last edited by
    #1

    I create a windows form application named p2pport. and I want to use the Message Map of MFC. so I use MFC with shared DLL and include afxwin.h. But When I compile it, it says that Debug Assertion Failed File : dbgheap.c line 144 Expression : _CrtIsValidHeapPointer(pUserData) I find it is because of the afxwin.h. I google it and found that it is a bug that was reported to MSDN. http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99715[^] I use that method to replace the main function and put #include in stdfax.h file. My original code is #include "stdafx.h" #include "Dlg.h" using namespace p2pport; [STAThreadAttribute] int main(void)//array ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it Application::Run(gcnew Dlg()); //Application::Run(gcnew Form2()); CMFCApp k; return 0; } And I modify it. #include "stdafx.h" #include "Dlg.h" using namespace p2pport; [STAThreadAttribute] class CMFCApp : public CWinApp { public: virtual BOOL InitInstance() { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it //Application::Run(gcnew Dlg()); return FALSE; } }theApp; But it comes the error. error C3115: 'System::STAThreadAttribute': this attribute is not allowed on 'theApp' I delete the [STAThreadAttribute]. It comes another two errors. error LNK2001: unresolved external symbol _main fatal error LNK1120: 1 unresolved externals I dont know how to solve it. I stuck it all day. Can anybody help me to solve the problem. Appreciate for ur reply Thx. Jane

    H 1 Reply Last reply
    0
    • M minihotto

      I create a windows form application named p2pport. and I want to use the Message Map of MFC. so I use MFC with shared DLL and include afxwin.h. But When I compile it, it says that Debug Assertion Failed File : dbgheap.c line 144 Expression : _CrtIsValidHeapPointer(pUserData) I find it is because of the afxwin.h. I google it and found that it is a bug that was reported to MSDN. http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99715[^] I use that method to replace the main function and put #include in stdfax.h file. My original code is #include "stdafx.h" #include "Dlg.h" using namespace p2pport; [STAThreadAttribute] int main(void)//array ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it Application::Run(gcnew Dlg()); //Application::Run(gcnew Form2()); CMFCApp k; return 0; } And I modify it. #include "stdafx.h" #include "Dlg.h" using namespace p2pport; [STAThreadAttribute] class CMFCApp : public CWinApp { public: virtual BOOL InitInstance() { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it //Application::Run(gcnew Dlg()); return FALSE; } }theApp; But it comes the error. error C3115: 'System::STAThreadAttribute': this attribute is not allowed on 'theApp' I delete the [STAThreadAttribute]. It comes another two errors. error LNK2001: unresolved external symbol _main fatal error LNK1120: 1 unresolved externals I dont know how to solve it. I stuck it all day. Can anybody help me to solve the problem. Appreciate for ur reply Thx. Jane

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      You must ask on the (Managed) C++/CLI[^].

      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