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
A

App_

@App_
About
Posts
23
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Restore folder to previous version?
    A App_

    Windows has a feature called Backup. Find it here , and a list of related actions here.

    C / C++ / MFC json help question announcement

  • SetTimer
    A App_

    A Universal TCP Socket Class for Non-blocking Server/Clients Single Threaded The function PumpMessages() processes all Windows messages which arrive in the application so the GUI stays responsive although the code runs an endless loop:

    // Set Timeout 50 ms
    mi_Socket.Listen(0, ms32_Port, 50);

    while (...) // This loop runs in the GUI thread
    {
    PumpMessages(); // process Windows messages

    DWORD u32\_Event;
    SOCKET  h\_Socket;
    // ProcessEvents() returns after 50 ms or after an event was received
    DWORD u32\_Error = mi\_Socket.ProcessEvents(&u32\_Event, &h\_Socket, ....);
    
    if (u32\_Error == ERROR\_TIMEOUT)
        continue;
    
    if (u32\_Event & FD\_ACCEPT) { /\* A new client has connected \*/ }
    if (u32\_Event & FD\_READ)   { /\* Data has been received \*/ }
    if (u32\_Event & FD\_CLOSE)  { /\* A socket has closed \*/ }
    
    if (u32\_Error) { /\* handle error \*/ }
    

    };

    C / C++ / MFC data-structures help question

  • How to copy One XMLdocument to another?
    A App_

    XmlDocument::ImportNode does the job, It states and i quote: "The ImportNode method is the mechanism by which a node or entire node subtree is copied from one XmlDocument to another. The node returned from the call is a copy of the node from the source document, including attribute values, the node name, node type, and all namespace-related attributes such as the prefix, local name, and namespace Uniform Resource Identifier (URI). The source document is not changed. " more from MSDN.. Code from MSDN:

    #using <System.Xml.dll>

    using namespace System;
    using namespace System::IO;
    using namespace System::Xml;
    int main()
    {

    //Create the XmlDocument.
    XmlDocument^ doc = gcnew XmlDocument;
    doc->LoadXml( "<bookstore><book genre='novel' ISBN='1-861001-57-5'><title>Pride And Prejudice</title></book></bookstore>" );

    //Create another XmlDocument which holds a list of books.
    XmlDocument^ doc2 = gcnew XmlDocument;
    doc2->Load( "books.xml" );

    //Import the last book node from doc2 into the original document.
    XmlNode^ newBook = doc->ImportNode( doc2->DocumentElement->LastChild, true );
    doc->DocumentElement->AppendChild( newBook );
    Console::WriteLine( "Display the modified XML..." );
    doc->Save( Console::Out );
    }

    C / C++ / MFC question html xml tutorial

  • How to extract Visio XML files properties
    A App_

    Visio Developer Center Visio SDK, code snippets Programming Visio with VBA Working with Connected Diagrams Programmatically Writing Code to Extract Data from a Visio Drawing

    C / C++ / MFC question xml tutorial

  • How to refresh folder
    A App_

    uh huh, I ripped that code from there :cool:

    C / C++ / MFC tutorial

  • How to refresh folder
    A App_

    Here you go.

    // Call for each explorer window

        HWND hExplorer = FindWindowEx(GetDesktopWindow(), NULL, L"ExploreWClass", NULL);
    
        while(hExplorer != NULL)
        {
            EnumChildWindows(hExplorer, RefreshFolderSelectionCB, (LPARAM)&packet);
    
            hExplorer = FindWindowEx(GetDesktopWindow(), hExplorer, L"ExploreWClass", NULL);
        }
    

    ...
    ...
    ...

    BOOL CALLBACK RefreshFolderSelectionCB(HWND hWnd, LPARAM lParam)
    {
    WCHAR sBuffer[MAX_PATH] = {0};

    ::GetClassName(hWnd, sBuffer, MAX\_PATH);
    
    if (wcscmp(L"SysTreeView32", sBuffer) == 0)
    {
        RefreshFolderSelectionPacket\* pPacket = (RefreshFolderSelectionPacket\*)lParam;
    
        // Refreshes the tree nodes that match the contained full paths, and all their open descendants
        // Paths are updated by calling UpdateItem (below)
        // Cache is used across explorer instances to ensure no path is updated twice.
    
        RefreshSelection(pPacket);
    }
    
    return TRUE;
    

    }

    ...
    ...
    static void UpdateItem(IShellFolder* pDesktop, const std::wstring& rsFullPath)
    {
    PIDLIST_RELATIVE pIDL;

    if (SUCCEEDED(pDesktop->ParseDisplayName(NULL, NULL, (LPWSTR)rsFullPath.c\_str(), NULL, &pIDL, NULL)))
    {
        SHChangeNotify(SHCNE\_UPDATEITEM, SHCNF\_IDLIST|SHCNF\_NOTIFYRECURSIVE|SHCNF\_FLUSH, pIDL, NULL);
    
        ILFree(pIDL);
    }
    

    }

    C / C++ / MFC tutorial

  • Splitter with fixed size
    A App_

    Does this help? If not, more here on splitters.

    C / C++ / MFC algorithms help question

  • how to Add the help file in SDI Application
    A App_

    MSDN says: The following example calls the HH_DISPLAY_TOPIC command to open the help file named Help.chm and display its default topic in the help window named Mainwin. Generally, the help window specified in this command is a standard HTML Help Viewer. MSDN Example

    HWND hwnd =
    HtmlHelp(
    GetDesktopWindow(),
    "c:\\Help.chm::/Intro.htm>Mainwin",
    HH_DISPLAY_TOPIC,
    NULL) ;

    C / C++ / MFC help tutorial

  • SetCurrentDirectory
    A App_

    #include <windows.h>
    #include <stdio.h>
    #define BUFFER_SIZE 200

    int main()
    {
    TCHAR infoBuf[BUFFER_SIZE];

    // Change accordingly to other path of your machine
    TCHAR lpPathName[200] = "c:\\";

    // get the current working directory
    if(!GetCurrentDirectory(BUFFER_SIZE, infoBuf)) printf("GetCurrentDirectory() failed!\n");

    printf("Your current directory is: %s\n", infoBuf); printf("Changing directory...\n");

    // set to current working directory
    if(!SetCurrentDirectory(lpPathName)) printf("SetCurrentDirectory() failed!\n");

    // do some verification...
    if(!GetCurrentDirectory(BUFFER_SIZE, infoBuf)) printf("GetCurrentDirectory() failed!\n");

    printf("Your current directory is: %s\n", infoBuf);

    // get and display the Windows directory.
    if(!GetWindowsDirectory(infoBuf, BUFFER_SIZE)) printf("GetWindowsDirectory() failed!\n");

    printf("Your Windows directory is: %s\n", infoBuf);

    // get and display the system directory.
    if(!GetSystemDirectory(infoBuf, BUFFER_SIZE)) printf("GetSystemDirectory() failed!\n");

    printf("Your system directory is: %s\n", infoBuf);

    return 0;
    }

    C / C++ / MFC tutorial

  • working with byte arrays
    A App_

    is done like this:

    #include <iostream>
    using namespace std;

    void charray(char test[]) {
    strncpy(test,"test",sizeof(test));
    }

    int main() {
    char test[256]={' '};
    charray(test);
    printf("Text in %s!\n", test);
    return 0;
    }

    C / C++ / MFC data-structures tutorial question

  • working with byte arrays
    A App_

    :thumbsup:

    C / C++ / MFC data-structures tutorial question

  • Function pointer point to a object member function in C++?
    A App_

    Class Math <--- error
    {
    public float add(float a, float b)
    {
    return a+b;
    }
    }<--- error

    Firstly , lowercase. Class Math should be class Math secondly , semicolon

    C / C++ / MFC help csharp c++ design regex

  • TCP Communication
    A App_

    source code here

    C / C++ / MFC tutorial

  • Suggest a fast way to do?
    A App_

    crc32 here and here

    C / C++ / MFC question

  • setting form element values using ie TCppWebBrowser control
    A App_

    What you are likely seeing is a call to MessageBox() before the exception is thrown. To turn that off, you can go into the Project Options and add NO_PROMPT_ON_HRCHECK_FAILURE to the Conditionals list. The exception will then be thrown without any prompting. If you are still using the TComInterface wrapper, the '->' operator validates whether the interface pointer is available or not. If it is not, an ASSERT is thrown. To disable the prompt on that error, you can define NO_PROMPT_ON_ASSERTE_FAILURE in the Project Options. If you implement a try..catch block, it will catch errors normally without messagebox prompt interruptions. (sample try catch)

    try {
    buf = new char[512];
    if( buf == 0 ) throw "Memory allocation failure!";
    }
    catch( char * str ) {
    cout << "Exception raised: " << str << '\n';
    }

    C / C++ / MFC c++

  • setting form element values using ie TCppWebBrowser control
    A App_

    Change this line:

    HRESULT __fastcall GetHTMLItem(ParentIntf *CollectionOrElement, const WideString &name, ItemIntf** ppIntf)

    To this:

    HRESULT __fastcall GetHTMLItem(TComInterface<ParentIntf> &CollectionOrElement, const WideString &name, ItemIntf** ppIntf)

    C / C++ / MFC c++

  • setting form element values using ie TCppWebBrowser control
    A App_

    I hope this Boland C++ Builder 6 code might work..

    #include utilcls.h
    #include Mshtml.h

    template<class ParentIntf, class ItemIntf>
    HRESULT __fastcall GetHTMLItem(ParentIntf *CollectionOrElement, const
    WideString &name, ItemIntf** ppIntf)
    {
    TVariant vName = name;
    TVariant vIndex = 0;
    TComInterface disp;

    HRESULT hRes = CollectionOrElement->item(vName, vIndex, &disp);
    if( SUCCEEDED(hRes) )
    hRes = disp->QueryInterface(\_\_uuidof(ItemIntf),(LPVOID\*)ppIntf);
    return hRes;
    

    }

    void __fastcall TForm1::CppWebBrowser1DocumentComplete (TObject*
    Sender, LPDISPATCH pDisp, TVariant *URL)
    {
    if( CppWebBrowser->Document )
    {
    TComInterface HTMLDoc;
    if(SUCCEEDED(CppWebBrowser->Document->QueryInterface(
    IID_IHTMLDocument2,(LPVOID*)&HTMLDoc) ) )
    {
    TComInterface forms;
    if( SUCCEEDED(HTMLDoc->get_forms(&forms)) )
    {
    TComInterface form;
    if( SUCCEEDED(GetHTMLItem(forms, "loginform", &form)) )
    {
    TComInterface userid;
    TComInterface password;

    			GetHTMLItem(form, "userid", &userid);
    			GetHTMLItem(form, "password", &password);
    
    			if( userid )
    			userid->put\_value(WideString("username"));
    
    			if( password )
    			password->put\_value(WideString("password"));
    			}
    		}
    	}
    }
    

    }

    I hope this Boland C++ Builder 6 code might work too..

    bool TForm1::Login(char* inputname, const AnsiString& text)
    {
    bool done = false;

    IHTMLDocument2* HTMLDoc = NULL;

    if(SUCCEEDED(CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&HTMLDoc)))
    {
    IHTMLElementCollection* pAll = NULL;
    if(SUCCEEDED(HTMLDoc->get_all(&pAll)))
    {
    //

    Variant name = inputname;
    Variant index = 0;

    IDispatch* pDisp = NULL;

    if(SUCCEEDED(pAll->item(name, index, &pDisp)))
    {
    if ( pDisp )
    {
    // IHTMLInputFileElement* pInput = NULL; // mshtml.h
    IHTMLInputElement* pInput = NULL; // mshtml.h
    // IHTMLFormElement* pForm = NULL; // mshtml.h

    pDisp->QueryInterface(IID\_IHTMLInputElement, (LPVOID\*)&pInput);
    pDisp->Release();
    
    if(pInput)
    {
     pInput->put\_value(WideString(text));
    
     done = true;
    
      /\*
      WideString mybuffer;
      pInput->get\_value ( &mybuffer );
      ShowMessage ( mybuffer );
      \*/
    
     pInput->Release();
     }
    }
    

    }
    pAll->Release();
    }

    HTMLDoc->Release();
    }
    return done;
    }

    C / C++ / MFC c++

  • Suggest a third party library for MFC applications
    A App_

    Yes QtGui on Linux. I's so easy to learn , like so:

    #include int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QLabel label("Hello, world!");
    label.show();
    return app.exec();
    }

    more here Why even use windows? Wall street trading systems all use Red Hat/SUSE. Windows is mostly relegated to the back office, Windows typically has larger latency times than that of Linux.

    C / C++ / MFC performance c++ design algorithms

  • MFC - how to get an edit box text from another dialog?? (Constructor)
    A App_

    use DDX_Text An example of DDX_Text usage

    C / C++ / MFC question c++ help tutorial

  • How to get list of COM Ports in Win32
    A App_

    Have a look there

    C / C++ / MFC com json tutorial
  • Login

  • Don't have an account? Register

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