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
J

Jonathan Craig

@Jonathan Craig
About
Posts
58
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • <TITLE> tag value server side
    J Jonathan Craig

    How can you get the value of the page's HTML TITLE tag in .NET server side code? Thanks for any help...:confused: Jonathan Craig mcw-tech.com

    ASP.NET csharp html com sysadmin help

  • common problem, multiple clicks
    J Jonathan Craig

    r i s h a b h s, Paul's has a good solution. If you don't want to use a cookie you can do something like this on the postback: ---- ASP Code ------------

    dim sBtnDisabled
    sBtnDisabled = ""

    if Request.Form("submit") = "Submit" then
    sBtnDisabled = "disabled"
    end if

    --- HTML Code ------------

    >

    Good Luck :) Jonathan Craig mcw-tech.com

    Web Development help javascript question

  • CString to CComBSTR to use for IDirectorySearch
    J Jonathan Craig

    You should be able to do it like this...

    CString str("Hack on!");
    BSTR bstr = str.AllocSysString();

    CComBSTR bstrTemp;
    bstrTemp.Attach(bstr);

    Hack on... :) Jonathan Craig www.mcw-tech.com

    C / C++ / MFC database question

  • Newbie: (Safely) deleting files
    J Jonathan Craig

    If you wish to send files to the recycle bin instead of just deleting them, use the SHFileOperation(...) function. It is a little tricky to use, but you can do a lot of cool stuff with it. See the MSDN. Hack on!:) Jonathan Craig www.mcw-tech.com

    C / C++ / MFC html help

  • Printing Landscape on Windows 2000
    J Jonathan Craig

    I need help trying to programmatically print in landscape mode use Windows 2000. The code below works on Windows 9x but not on Windows 2000:

    ...
    printerDC.StartPage();

    DEVMODE dm;
    memset(&dm, 0, sizeof(dm));
    dm.dmSpecVersion = DM_SPECVERSION;
    dm.dmSize = sizeof(DEVMODE);
    dm.dmFields = DM_ORIENTATION;
    dm.dmOrientation = DMORIENT_LANDSCAPE;

    printerDC.ResetDC(&dm);
    ...

    Under Windows 2000 the page is printed portait mode. I have looked in the MSDN, no help... Thanks in advance! :) Jonathan Craig www.mcw-tech.com

    C / C++ / MFC com help

  • Thread
    J Jonathan Craig

    Set the dwCreateFlags parameter to CREATE_SUSPENDED. CWinThread* pThread = AfxBeginThread(pfnThreadProc, pParam, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); When you are ready for the thread to start execution call this: pThread->ResumeThread(); :) Jonathan Craig www.mcw-tech.com

    C / C++ / MFC com question

  • GetDocument in a dialog?
    J Jonathan Craig

    will1383, DavidCrow has a good idea, but remember that the default constructor for a dialog is: CMyDialog(CWnd *pParent); So you should create it like this: CMyDialog dlg(this); The this parameter being a pointer to the parent window. It is good practice to always set the parent for a dialog. Don't create them like this: CMyDialog dlg; If you do dialogs can sometimes not come to the top or fall behind other windows. So define your new constructor like so: CMyDialog(CWnd *pParent, CMyDoc *pDoc); Now create your dialog like this: CMyDialog dlg(this, GetDocument()); Now you have the best of both. :) Jonathan Craig www.mcw-tech.com

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

  • prob. regarding release and debug build
    J Jonathan Craig

    One classic reason for this is to define a ON_MESSAGE handler incorrectly. The prototype for the ON_MESSAGE hander is: afx_msg long OnMyMessage(WPARAM wParam, LPARAM lParam); But, if you define it like this: afx_msg **void** OnMyMessage(WPARAM wParam, LPARAM lParam); It will work fine in debug mode and crash in release mode. You get no warnings and it can be very, very hard to debug (because it works in debug mode). This one has got me before. It took about 2 days to figure it out. Hope this helps... :) Jonathan Craig www.mcw-tech.com Jonathan Craig www.mcw-tech.com

    C / C++ / MFC help debugging announcement

  • detecting exceptions in threads
    J Jonathan Craig

    The only way for your program to crash from an exception is from an unhanded exception. Unhanded exceptions are bugs! Make sure you catch your exceptions. When an exception occurs; notify the dialog, stop all threads, and restart the threads. There is not need to have a 2nd application watching and restarting. If your application requires a complete restart to get things going again, reorganize your code. It needs to be more object oriented. Hack on! :) Jonathan Craig www.mcw-tech.com

    C / C++ / MFC c++ design question

  • Thread
    J Jonathan Craig

    Gandilf emailed me: Your struct trick works perfectly but now I got an exception 0xC0000005 about metProfPtr. metProfPtr is a pointer to the current dialog (my own progress bar and bitmap, etc...). I need it to unhide one different bitmap at each process completion (total of processes: 6). When you talk about initializing pointer metprofPtr like td.pDoc = CTestSDIDoc::GetDoc(); for pDoc, what can I do ? (td.metProfPtr = 0 ?) Maybe you have another suggestion. Thanks a lot, Rene There are two different ways to do it. 1.) Add the pointer to the dialog to the ThreadData struct.

    struct ThreadData
    {
    .
    CMyDialog *pDlg;
    .
    };

    td.pDlg = this;

    This may or may not cause problems when calling methods on td->pDlg. 2.) If you know which object you wish to hide or show, you can pass a HWND handle to it. If your bitmap object is a CStatic.

    struct ThreadData
    {
    .
    HWND hWnd;
    .
    };

    td.hWnd = m_bitmap.GetSafeHwnd();

    In your thread you would call.

    ::ShowWindow(td->hWnd, SW_HIDE);

    or

    ::ShowWindow(td->hWnd, SW_SHOW);

    This is the correct way to pass window objects to a thread. Good Luck :) Jonathan Craig www.mcw-tech.com

    C / C++ / MFC debugging question career

  • Thread
    J Jonathan Craig

    Pass all the data the thread will need as the parameter:

    struct ThreadData
    {
    CTestSDIDoc *pDoc;
    metprof *metProfPtr;
    .
    . //Your data here.
    .
    HWND hWnd; //Pass CWnd objects by HWND.
    };

    .
    .
    .
    ThreadData *td = new ThreadData

    //Do this before starting thread.
    td.pDoc = CTestSDIDoc::GetDoc();
    td.metProfPtr = ... //Set this too.

    //Thread function must delete td!
    CWinThread *pThread = AfxBeginThread(ThreadProc, (LPVOID)td);
    .
    .
    .

    UINT ThreadProc(LPVOID lpParam)
    {
    ThreadData *td = (ThreadData *)lpParam;
    .
    . //Your code here.
    .
    delete td; //Delete memory so no leaks.
    return 0;
    }

    Also, you don't need a thread just to create a proccess. Hope this helps... :) Jonathan Craig www.mcw-tech.com

    C / C++ / MFC debugging question career

  • Navigation Bar
    J Jonathan Craig

    Thanks for the info. My first idea was to parse the URL but thought I would check the board first. I don't want to recreate the wheel. Thanks again, :) Jonathan Craig www.mcw-tech.com

    ASP.NET csharp asp-net com question

  • Create a WinZip file and is there a way to prevent winzip from reading it
    J Jonathan Craig

    Winzip does support command line parameters, it is a add-on. You can download it from their web site. Jonathan Craig www.mcw-tech.com

    C / C++ / MFC question

  • Create a WinZip file and is there a way to prevent winzip from reading it
    J Jonathan Craig

    If you want custom stuff you can use the PKWARE Data Compression Library. I have use them before to compress very large amounts of data. They allow you to create your own file formats and use PKZIP quality compression. http://www.pkware.com/products/developers/dcl/ Jonathan Craig www.mcw-tech.com

    C / C++ / MFC question

  • Navigation Bar
    J Jonathan Craig

    I want to add a navigation bar to the top of my web pages like the one on Code Project just below the Search box: CodeProject.com >> Forums home page >> ASP.NET It there an article on the site for this or does someone have a code snipplet? Thanks :) Jonathan Craig www.mcw-tech.com

    ASP.NET csharp asp-net com question

  • How to prevent pages from expiring??
    J Jonathan Craig

    I have not looked at my ASP stuff in a while, but I thought the page expiration time is set throught IIS setup. The meta tag HTTP-EQUIV="Expires" may also help. Sorry, if this is of no use. :confused: Jonathan Craig www.mcw-tech.com

    ASP.NET help question csharp asp-net tutorial

  • PrintDlgEx, Visual C++ 6.0, and the Platform SDK
    J Jonathan Craig

    I don't see anywhere in the SDK include files a reference to _WIN_NT. I have added #define _WIN32_WINNT 0x0500 and #define WINVER 0x0500 to the stdafx.h file but I still get the same error. Jonathan Craig www.mcw-tech.com

    C / C++ / MFC c++ question com help

  • PrintDlgEx, Visual C++ 6.0, and the Platform SDK
    J Jonathan Craig

    I'm trying to use the PrintDlgEx method with Visual C++ 6.0. I have installed the Platform SDK (October 2002) and the include, lib, and exe directories for this are first in the directories option. But I keep getting "error C2065: 'PRINTDLGEX' : undeclared identifier." It appears the complier is not look at the stuff in my "C:\Microsoft SDK" directories. So what is required to get Visual C++ using the Platform SDK includes, libs, and exes? Thanks for all input ;) Jonathan Craig www.mcw-tech.com

    C / C++ / MFC c++ question com help

  • Document Class and Dialog Windows :: MFC
    J Jonathan Craig

    I'm sure there are a million answers to your question. But I would stick to the message solution. It is the best way for windows to communicate. I would not pass pointers to class objects around to be used. That could be potentially dangerous. If the WPARAM and LPARAM parameters seem to limiting remember you can allocate memory (or objects; classes, structs, etc.) and pass the pointer to another window through a message.

    if(IsWindow(hwnd))
    {
    CThing *pThing = new CThing;
    PostMessage(hwnd, WM_NEW_THING, 0, (LPARAM)pThing);
    }

    Just remember the receiver of the message is responible for deleting the memory.

    long CMyWnd::OnNewThing(WPARAM wParam, LPARAM lParam)
    {
    ASSERT(lParam);
    CThing *pThing = (CThing *)lParam;
    ...
    delete pThing;
    }

    One more thing, in the OnDestory method of the CWnd class make sure you have no more WM_NEW_THING messages in the queue. Their memory should be deleted if they are.

    MSG msg;
    while(::PeekMessage(&msg, (HWND)NULL, WM_NEW_THING, WM_NEW_THING, PM_REMOVE))
    {
    CThing *pThing = (CThing *)msg.lParam;
    delete pThing;
    }

    Hope this helps. Jonathan Craig www.mcw-tech.com

    C / C++ / MFC c++ tutorial question announcement lounge

  • Help! ON_UPDATE_COMMAND_UI Not called prior to menu display
    J Jonathan Craig

    See my reply to another post: http://www.codeproject.com/script/comments/forums.asp?msg=187019&forumid=1647&kw=Jonathan+Craig#xx187019xx. If each of your CView classes can handle the messages, then it is just a matter of getting the messages to the correct view. You may need to customize the CSplitterWnd::OnCmdMsg override to route the message to all the views. :) Jonathan Craig www.mcw-tech.com

    C / C++ / MFC help question announcement
  • Login

  • Don't have an account? Register

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