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
P

Peter Ritchie

@Peter Ritchie
About
Posts
46
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • I sometimes despair of MS [modified Someone, sort of, agrees with me]
    P Peter Ritchie

    have a look at http://blogs.msdn.com/fxcop/archive/2007/08/09/what-rules-do-microsoft-have-turned-on-internally.aspx[^]

    PeterRitchie.com

    The Lounge csharp c++ delphi com design

  • Certificate verification using CRL
    P Peter Ritchie

    Have you set the X509Chain.ChainPolicy.RevocationMode to X509RevocationMode.Online?

    PeterRitchie.com

    C# csharp windows-admin cryptography question

  • codeproject.com in Google searches
    P Peter Ritchie

    I'm finding that Google usually spits out several results for the same article on codeproject.com. For example, the following Google search results in four of about 4460 hits for the same article: "RTF comments field" site:codeproject.com[^] Some of the other links are different forms of the same article, like "print" for example. But, most of the links are links with the same page for navigating the article's forum. Might I suggest that these links have the attribute/value pair rel="nofollow" added to them so Google's Googlebot and other search engines' bots can choose not to index the same article multiple times? I'm sure this would reduce the bandwidth that Google uses to index the site tremendously (if 4460 accesses to http://www.codeproject.com/tools/ToDoList2.asp is any indication) PeterRitchie.com

    Site Bugs / Suggestions database com tools tutorial question

  • CDatabase question
    P Peter Ritchie

    Each database is slightly different when it comes to raw SQL when querying schema data. MSDE/SQL Server, for example, store some schema information in the sysobject table. For a list of table names you can run the following query:

    SELECT name
    FROM sysobjects
    WHERE (xtype = 'U')
    ORDER BY name

    For a more generic method you'll have to resort to direct calls to ODBC. There's a sample at MS that does this sort of thing with CDatabase: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/_sample_mfc_catalog2.asp[^] PeterRitchie.com

    C / C++ / MFC question database com tutorial

  • BrowseFolders Dialog on Win2k/IE5?
    P Peter Ritchie

    Then you've got a GUID to a virtual folder that does not have a physical location for it. PeterRitchie.com

    C / C++ / MFC linux help tutorial question

  • Setting Style (SetStlye Method) With API
    P Peter Ritchie

    If it's a stand-alone application (i.e. not client-server) then I would suggest just writing it in C++. The work involed in marshalling all the API structures and data just isn't work the time otherwise. If speed is that much of an issue for you. Even with .NET 2.0 there are some performance differences between .NET applications and "native"/unmanaged. see http://www.sysinternals.com/blog/#111409937327999900[^] PeterRitchie.com

    .NET (Core and Framework) csharp dotnet wpf json

  • system files
    P Peter Ritchie

    See [SetupIterateCabinet](http://msdn.microsoft.com/library/en-us/setupapi/ setup/setupiteratecabinet.asp)[[^](http://msdn.microsoft.com/library/en-us/setupapi/ setup/setupiteratecabinet.asp)] PeterRitchie.com

    C / C++ / MFC tutorial

  • Image Printing
    P Peter Ritchie

    In your CView-derived class's OnDraw:

    CBitmap bmp;
    if (bmp.LoadBitmap(IDB_BITMAP1))
    {
    // Get the size of the bitmap
    BITMAP bmpInfo;
    bmp.GetBitmap(&bmpInfo);

      // Create an in-memory DC compatible with the
      // display DC we're using to paint
      CDC dcMemory;
      dcMemory.CreateCompatibleDC(pDC);
    
      // Select the bitmap into the in-memory DC
      CBitmap\* pOldBitmap = dcMemory.SelectObject(&bmp);
    
      // Find a centerpoint for the bitmap in the client area
      CRect rect;
      GetClientRect(&rect);
      int nX = rect.left + (rect.Width() - bmpInfo.bmWidth) / 2;
      int nY = rect.top + (rect.Height() - bmpInfo.bmHeight) / 2;
    
      // Copy the bits from the in-memory DC into the on-
      // screen DC to actually do the painting. Use the centerpoint
      // we computed for the target offset.
      pDC->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory, 
         0, 0, SRCCOPY);
    
      dcMemory.SelectObject(pOldBitmap);
    

    }

    PeterRitchie.com

    C / C++ / MFC question c++ performance

  • BrowseFolders Dialog on Win2k/IE5?
    P Peter Ritchie

    You can convert the file object's display name into a path with the following:

    /// <summary>
    /// Sample that converts a textual file/folder object display name
    /// (::{GUID} format) to a physical path (if possible)
    /// </summary>
    /// <author> Peter A. Ritchie</author>
    /// <date type="creation">26-Apr-2005</date>

    CComPtr<IShellFolder> pshf = NULL**;**

    ::SHGetDesktopFolder**(&pshf)****;**
    LPITEMIDLIST pidlDocFiles**;**
    ULONG cbEaten**;**
    pshf->ParseDisplayName**(NULL,**

    NULL**,** 
    L"::{450d8fba-ad25-11d0-98a8-0800361b1103}"**,** 
    &cbEaten**,** 
    &pidlDocFiles**,** 
    NULL**)****;**
    

    TCHAR szPath**[MAX_PATH]** = _T**("")****;**

    ::SHGetPathFromIDList**(pidlDocFiles,** szPath**)****;**

    But, I'm curious, how are you getting the display name "::{GUID}"? Are you using SHBrowseForFolder? If so, what are you doing with the PIDL? PeterRitchie.com

    C / C++ / MFC linux help tutorial question

  • About scrollbar of CScrollView
    P Peter Ritchie

    Why in the world would you want to contradict standard Windows usability and provide scrolling without a scrollbar? Why would your users want to re-learn how to scroll, just for your application? Then, have to deal with different mouse gestures as they switch between your applications and all other Windows applications? What happens if your users don't have mouse with a scroll wheel? CScrollView-derived views cannot simply have their scroll bars "hidden"; they are integral to the window. You would probably have to override the non-client size calculations and drawing. PeterRitchie.com

    C / C++ / MFC c++

  • Setting Style (SetStlye Method) With API
    P Peter Ritchie

    Are you using the Win32 API, via P/Invoke? Why are you using .NET at all if you're simply doing everything via Win32 API? PeterRitchie.com

    .NET (Core and Framework) csharp dotnet wpf json

  • List installed screensavers
    P Peter Ritchie

    .NET doesn't have support for Win32 resources. You have to pinvoke LoadStringW from kernel32. A little helper class:

    using System;
    using System.Runtime.InteropServices;
    using System.Text;

    namespace PeterRitchie
    {
    /// <summary>
    /// Helper class for various things
    /// </summary>
    [ComVisible(false)]
    sealed class Helper
    {
    [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
    private static extern IntPtr LoadLibrary(string lpFileName);
    [DllImport("user32", EntryPoint="LoadString")]
    private static extern int LoadStringW(int hInstance, int wID, [Out] StringBuilder lpBuffer, int nBufferMax) ;

    	/// <summary>
    	/// Load a Win32 Resource string.
    	/// </summary>
    	/// <param name="ModuleFilePathString">Module to load from</param>
    	/// <param name="ID">ID or index of the string</param>
    	/// <param name="LoadedString">Destination reference</param>
    	public static void LoadString(String ModuleFilePathString, int ID, ref String LoadedString)
    	{
    		IntPtr InstanceHandle = LoadLibrary(ModuleFilePathString);  
    
    		StringBuilder BufferString = new StringBuilder(1024);
    
    		LoadStringW(InstanceHandle.ToInt32(), ID, BufferString, BufferString.Capacity);
    		LoadedString = BufferString.ToString();
    	}
    }
    

    };

    Sample usage:

    using PeterRitchie;
    string LoadedString = "";
    Helper.LoadString(@"C:\\windows\\system32\\ssbezier.scr", 1, ref LoadedString);
    Debug.WriteLine(LoadedString);
    

    Enjoy! PeterRitchie.com

    .NET (Core and Framework) windows-admin help question

  • List installed screensavers
    P Peter Ritchie

    The string resource with ID 1 is used as the title to display in Display control panel applet. PeterRitchie.com

    .NET (Core and Framework) windows-admin help question

  • Setting Style (SetStlye Method) With API
    P Peter Ritchie

    Okay, you've misused the work API--which is an interface (or a group of functions/methods). You're looking for all the methods that perform the same thing as SetStyle for each bit... There normally isn't a one-to-one correspondance with a style bit and a method or a function. Many of the styles shouldn't be changed after the window has been created, they're ment to be used as the window is being created where calling a dozen or so methods instead of SetStyle would be tedious. Even in other APIs like MFC hyou have to resort to SetStyle (which wraps SetWindowsLong(GWL_STYLE,...) ). Some of the styles in ControlStyles are .NET specific; meaning they're only handled as a cohesive attribute in .NET. I don't know of any exhaustive lists that would give you the information you want. Maybe you could detail what you want to do or why simply calling SetStyle doesn't suit your needs. PeterRitchie.com

    .NET (Core and Framework) csharp dotnet wpf json

  • System.Security.SecurityException - Project won&#180;t run online
    P Peter Ritchie

    If the exception is because you're accessing a remote share, then the workaround would be not to use the remote share--copy the files that are being accessed in the share to the web server. PeterRitchie.com

    ASP.NET database sql-server com sysadmin windows-admin

  • Single Precision not precise
    P Peter Ritchie

    Yes, anyone who has done any floating-point calculations on a computer has run into this. Welcome to floating-point. PeterRitchie.com

    .NET (Core and Framework) csharp help question

  • MSVC6 to C++.Net Migration
    P Peter Ritchie

    If by C++.net you mean managed C++, I would start with a .NET introduction. Most of the language-specific aspects of .NET documentation (i.e. books) aren't geared much towards C++--they concentrate on C# or VB. PeterRitchie.com

    .NET (Core and Framework) csharp c++ visual-studio algorithms beta-testing

  • Interpolating
    P Peter Ritchie

    Unless you draw your image in it's exact size (or a multiple of its size) interpolation *must* occur. If you're drawing the exact size, there's no interpolation. PeterRitchie.com

    .NET (Core and Framework) graphics design help question

  • Get object name
    P Peter Ritchie

    You would have to manually parse the debugging information; which, of course, does not exist in release builds. The best you could hope for is the address (using the &[^] Operator in an unsafe[^] context). PeterRitchie.com

    .NET (Core and Framework) csharp css help

  • List installed screensavers
    P Peter Ritchie

    Yep it just lists the *.SCR files that impelement the screen saver entry points. PeterRitchie.com

    .NET (Core and Framework) windows-admin help 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