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
S

Sternocera

@Sternocera
About
Posts
86
Topics
34
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • UAC and restarting an external service in my MFC app
    S Sternocera

    Hi, Doing so doesn't make any discernible difference, Regards, Sterncera

    C / C++ / MFC c++ com sysadmin security business

  • UAC and restarting an external service in my MFC app
    S Sternocera

    Hi, I have an MFC app that is dependant on an external windows service. The need to restart that service occasionally arises. I do this using some boilerplate code, heavily derivative of that appearing in an article on MSDN. When I run the application on Vista as a non-administrator, a call to OpenSCManager() returns NULL. I must run the application as an administrator for the process to succeed. Can I make a UAC dialog automatically appear on Vista/7 in the event of needing to access administrative functions like this? I have similar problems in the same application when calling code that uses boost.asio to ping a remote server. I'm not sure if it's relevant, but here is my application manifest security entry:

    <!-- Identify the application security requirements. -->
    <ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-
    com:asm.v2">
    <ms_asmv2:security>
    <ms_asmv2:requestedPrivileges>
    <ms_asmv2:requestedExecutionLevel level="highestAvailable">
    </ms_asmv2:requestedExecutionLevel>
    </ms_asmv2:requestedPrivileges>
    </ms_asmv2:security>
    </ms_asmv2:trustInfo>

    Thanks a lot, Sternocera

    C / C++ / MFC c++ com sysadmin security business

  • Problem with icon style CListCtrl on Vista, but not on XP
    S Sternocera

    I haven't had a re-occurrence since I simply initialised my structs, but thanks for pointing that out.

    C / C++ / MFC c++ graphics sales help question

  • Problem with icon style CListCtrl on Vista, but not on XP
    S Sternocera

    Hi Mike, Yes, imgl is declared in the same class definition as the CListCtrl. I have now zero initialised the LVITEM structs. Thanks for your help. Regards, Sternocera

    C / C++ / MFC c++ graphics sales help question

  • Problem with icon style CListCtrl on Vista, but not on XP
    S Sternocera

    That seems like a reasonable explanation. I've found that moving the initialisation of the icons into OnIntialUpdate seems to fix the problem, but I'm not overly confident that it hasn't just temporarily concealed the problem. I'll delete the cache to be sure. Regards, Sternocera

    C / C++ / MFC c++ graphics sales help question

  • Problem with icon style CListCtrl on Vista, but not on XP
    S Sternocera

    Hi Randor, I'm not - it isn't a report style CListCtrl, it's an icon style CListCtrl. I understand that column width isn't set with an icon style CListCtrl. Regards, Sternocera

    C / C++ / MFC c++ graphics sales help question

  • Problem with icon style CListCtrl on Vista, but not on XP
    S Sternocera

    I seem to have isolated the problem somewhat (It still erratically tends to swing between omitting and not omitting the icon between builds, I guess). By commenting out: ReportsCtrl.ModifyStyle(0, LVS_AUTOARRANGE); I can make the problem disappear (although I have a new problem, which is that the icons are displayed as one big column). Commenting out anything else of note doesn't have the effect of suppressing the problem, so I guess that's progress. Regards, Sternocera

    C / C++ / MFC c++ graphics sales help question

  • IcmpSendEcho error: 1231
    S Sternocera

    If you want to use ping from your application, have a look at boost::asio. Boost have a ping example program that you may be able to adopt. Note that your application requires administrative privileges on Vista to create ICMP packets. Regards, Sternocera

    C / C++ / MFC help sysadmin

  • Problem with icon style CListCtrl on Vista, but not on XP
    S Sternocera

    Hello, I'm working on an MFC application. For reasons I cannot fathom, there seems to be a problem with inconsistent display of the icons of an icon style CListCtrl between versions of Windows (XP and Vista). On Vista, one of the icons (Debtor statement) is omitted. This only occurs sometimes. When it actually occurs varies from build to build of the application, where changes between builds ought to have no bearing on this at all. Why might this be? How can the problem be fixed? Here is the relevant code: CMyReportView::OnInitialUpdate() { CFormView::OnInitialUpdate(); ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED); ReportsCtrl.ModifyStyle(0, LVS_AUTOARRANGE); // Send an ID_RELOAD rather than calling UpdateStateData() directly - this is // a hack to work around the problem of no icons being displayed initially // in release build SendMessage(ID_RELOAD ); }

    CMyReportView::UpdateData() // called when ID_RELOAD is received, sent from OnInitialUpdate
    {
    // Load your imagelist bitmap (bmp) here, however
    // you feel like (e.g. CBitmap::LoadBitmap)
    CBitmap sales_bitmap,
    daily_reconciliation_bitmap,
    debtor_statement_bitmap,
    debtor_invoice_bitmap,
    voided_items_bitmap,
    suspended_sales_bitmap,
    stock_count_rep_bitmap,
    live_stock_figures_bitmap,
    sales_by_item,
    pos_download_bitmap;

    sales\_bitmap.LoadBitmap(IDB\_SALES);
    daily\_reconciliation\_bitmap.LoadBitmap(IDB\_DAILY\_RECONCILIATION);
    debtor\_statement\_bitmap.LoadBitmap(IDB\_DEBTOR\_STATEMENT); 
    debtor\_invoice\_bitmap.LoadBitmap(IDB\_DEBTOR\_INVOICE); 
    voided\_items\_bitmap.LoadBitmap(IDB\_ICON\_VOID); 
    suspended\_sales\_bitmap.LoadBitmap(IDB\_SUSPENDED\_SALES\_ICON);
    stock\_count\_rep\_bitmap.LoadBitmap(IDB\_STOCK\_COUNT\_REPORT\_ICON);
    live\_stock\_figures\_bitmap.LoadBitmap(IDB\_ICON\_LIVE\_STOCK\_FIGURES);
    sales\_by\_item.LoadBitmap(IDB\_SALES\_BY\_ITEM\_ICON);
    pos\_download\_bitmap.LoadBitmap(IDB\_POS\_DOWNLOAD\_REPORT\_ICON);
    
    // Set up your transparent colour as appropriate
    COLORREF rgbTransparentColour = RGB(255, 255, 255);
    imgl.Create(64, 64, ILC\_MASK | ILC\_COLOR32, 0, 0);
    
    // Add the bitmap into the image list
    int sales\_bit\_id = imgl.Add(&sales\_bitmap, rgbTransparentColour);
    int daily\_rec\_bit\_id = imgl.Add(&daily\_reconciliation\_bitmap, rgbTransparentColour);
    int debtor\_stat\_bit\_id = imgl.Add(&debtor\_statement\_bitmap, rgbTransparentColour);
    int debt\_invo\_bit\_id = imgl.Add(&debtor\_invoice\_bitmap, rgbTransparentColour);
    int voided\_itms\_bit\_id = imgl.Add
    
    C / C++ / MFC c++ graphics sales help question

  • Displaying a chart in a CScrollView report.
    S Sternocera

    Hi Cédric, Great work with the charting control. The idea of a "stacked" bar (which is a name I just made up - there may be a better one) is that you can breakdown a bar into multiple sub-bars. Take a look at this image, generated with crystal reports: http://imagebin.ca/view/v2bIgfH5.html Can you think of a way of using you charting control within a CScrollView, writing to a device context? Regards, Sternocera

    modified on Friday, October 23, 2009 8:50 AM

    C / C++ / MFC c++ algorithms data-structures performance career

  • Displaying a chart in a CScrollView report.
    S Sternocera

    Hello, I'm maintaining an application that has a number of fairly simple reports displayed in a CScrollView, that use MFC's print/ print preview facilities, writing to a CDC (device context). I'd like to add some bar charts to the reports, to graph information (generally, how much of something occurred in a specified time period). It would be particularly useful if I could use "stacked" barcharts, where the bar is comprised of more than one type of record, grouped together. I've had excellent results with Cedric Moonen's high speed charting control when I needed this sort of functionality in dialogs (without the "stacked" charts, though). However, even after searching codeproject I'm not aware of any free or commercially available licence that is suitable for the task I've described. It wouldn't have to be explicitly an MFC library, just something that will get the job done. Regards, Sternocera

    C / C++ / MFC c++ algorithms data-structures performance career

  • Inconsistent results when using MFC printing with a CDC and CFormView with OnDraw implemented
    S Sternocera

    Hi, I'm performing printing of reports in an MFC app in what I think is a fairly canonical way...with a CDC and CFormView with OnDraw implemented. CDC's TextOut member functions and so on are called in OnDraw(). I get inconsistent results from printer model to printer model....The margins are different, and sometimes the important parts of my documents are actually cropped. Print preview accurately represents how the document will be (often incorrectly) printed. Is there some technique that allows me to calculate an offset for the specific model of printer in use on the fly, to compensate when drawing in OnDraw() - perhaps something to do with CDC::GetDeviceCaps()? It seems that the area of the page that my reports are "projected onto" varies somewhat (not terribly, but certainly enough for it to be a problem), but the scale is always correct. Thanks, Sternocera

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

  • Calling CFrameWnd::RecalcLayout causes slight flicker in left pane (CTreeView) of outlook style splitter app
    S Sternocera

    CFrameWnds may display views, or other CFrameWnds. They are, as the name suggests, for framing things. Regards, Sternocera

    C / C++ / MFC question c++

  • Calling CFrameWnd::RecalcLayout causes slight flicker in left pane (CTreeView) of outlook style splitter app
    S Sternocera

    Hello, I'm writing an MFC app that is in the style of MS outlook, with a CTreeView in the left hand pane, and a CFrameWnd, called CRightPaneFrame, that contains a view (which view varies, depending on which node on the CTreeView is selected) - a splitter application. In the function that switches views, called by the CTreeView, the final thing we do is call RecalcLayout(), to have everything (re)drawn. This causes slight, although noticeable flicker in the left pane, as the Main frame of the application is (apparently) redrawn. How can I prevent this flicker from occurring, by limiting redrawing to CRightPaneFrame and its current CView? According to MSDN, RecalcLayout is "Called by the framework when the standard control bars are toggled on or off or when the frame window is resized". This seems like overkill for this task (updating CRightPaneFrame/its underlying view). How all can I accomplish this task without redrawing my left pane? Regards, Sternocera

    C / C++ / MFC question c++

  • Problem with Visual studio 2008 feature pack's CMFCToolBar - not being displayed
    S Sternocera

    Hello, I'm upgrading my MFC application to make use of some of the new user interface elements from the Visual studio 2008 feature pack. My first concern is upgrading my CToolBar to the pack's new CMFCToolBar, to use large icons, rollover buttons, etc. I use much the same boilerplate code in CMainFrame::OnCreate() as ever:

    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
    return -1;

    // I've attempted to simplify the code to the greatest possible extent to isolate the problem:

    // The this pointer points to CMainFrame class which extends the CFrameWnd class.
    if (!m_wndToolBar.CreateEx (this, TBSTYLE_TRANSPARENT) ||
    !m_wndToolBar.LoadToolBar (IDR_MAINFRAME))
    {
    TRACE0("Failed to create toolbar\n");
    return -1; // fail to create
    }

    However, no toolbar is visible when the application starts - it is simply omitted. Switching the class of m_wndToolBar from CMFCToolBar back to CToolBar once again makes the toolbar visible. Why might the framework fail to display my CMFCToolBar? How can I fix the problem? Regards, Sternocera

    C / C++ / MFC help question csharp c++ visual-studio

  • Overcoming problem with std::min, std::max, #define NOMINMAX
    S Sternocera

    I've come up with this unfortunate hack:

    #define NOMINMAX
    #ifndef max
    #define max(a,b) (((a) > (b)) ? (a) : (b))
    #endif

    #ifndef min
    #define min(a,b) (((a) < (b)) ? (a) : (b))
    #endif
    #include <afxcontrolbars.h>
    #undef max
    #undef min
    // ...contine to use std::mix, std::max from here on

    When I undefined NOMINMAX, min and max were already defined, so it didn't matter. So, I've simply defined min and max just as they are defined from within WinDef.h . Regards, Sternocera

    C / C++ / MFC c++ help csharp database visual-studio

  • Overcoming problem with std::min, std::max, #define NOMINMAX
    S Sternocera

    Richard, Thanks for that. I should have mentioned that that was the first thing that I tried. The result was exactly the same compiler errors as when I don't #undef:

    1>------ Build started: Project: Lustre, Configuration: Debug Win32 ------
    1>Compiling...
    1>stdafx.cpp
    1>c:\program files\microsoft sdks\windows\v6.1\include\gdiplustypes.h(471) : error C3861: 'min': identifier not found
    1>c:\program files\microsoft sdks\windows\v6.1\include\gdiplustypes.h(472) : error C3861: 'min': identifier not found
    1>c:\program files\microsoft sdks\windows\v6.1\include\gdiplustypes.h(473) : error C3861: 'max': identifier not found
    1>c:\program files\microsoft sdks\windows\v6.1\include\gdiplustypes.h(474) : error C3861: 'max': identifier not found
    1>c:\program files\microsoft sdks\windows\v6.1\include\gdiplustypes.h(495) : error C3861: 'max': identifier not found
    1>c:\program files\microsoft sdks\windows\v6.1\include\gdiplustypes.h(496) : error C3861: 'max': identifier not found
    1>c:\program files\microsoft sdks\windows\v6.1\include\gdiplustypes.h(497) : error C3861: 'min': identifier not found

    I guess that exactly the same error message appears because stdafx.h is included in some header that is included somewhere, directly or indirectly, in gdiplustypes.h et al, which are included in afxcontrolbars.h. Regards, Sternocera

    C / C++ / MFC c++ help csharp database visual-studio

  • Overcoming problem with std::min, std::max, #define NOMINMAX
    S Sternocera

    Hello, I'm writing/maintaining an MFC app that makes extensive use of a database API that uses std::min and std::max, which is used in most of the application's translation units. Therefore, it makes sense to include the APIs convenience header (which in turn includes everything) in stdafx.h. The API requires that I #define NOMINMAX, so that the C++ std library's min and max function templates are used, rather than MS's legacy min and max macros. I have #define'd NOMINMAX in stdaxf.h . This worked fine for a long time. However, I recently installed the MFC 2008 feature pack. I must now #include afxcontrolbars.h. However, this header has inline functions that are dependent on the min and max macros which are now missing. I tried to "#include algorithm; using std::min; using std::max;" immediately before I include afxcontrolbars.h, so that std::min and std::max would be used as drop in replacements for the macros (this has worked in other areas in the past) but stdafx.cpp still doesn't build:

    1>Compiling...
    1>stdafx.cpp
    1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtoolbar.h(166) : error C2782: 'const _Ty &std::max(const _Ty &,const _Ty &)' : template parameter '_Ty' is ambiguous
    1> c:\program files\microsoft visual studio 9.0\vc\include\xutility(3356) : see declaration of 'std::max'
    1> could be 'LONG'
    1> or 'int'
    1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtoolbar.h(166) : error C2780: 'const _Ty &std::max(const _Ty &,const _Ty &,_Pr)' : expects 3 arguments - 2 provided
    1> c:\program files\microsoft visual studio 9.0\vc\include\xutility(3364) : see declaration of 'std::max'
    1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxmenubar.h(161) : error C2782: 'const _Ty &std::max(const _Ty &,const _Ty &)' : template parameter '_Ty' is ambiguous
    1> c:\program files\microsoft visual studio 9.0\vc\include\xutility(3356) : see declaration of 'std::max'
    1> could be 'LONG'
    1> or 'int'
    1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxmenubar.h(161) : error C2780: 'const _Ty &std::max(const _Ty &,const _Ty &,_Pr)' : expects 3 arguments - 2 provided
    1> c:\program files\microsoft visual studio 9.0\vc\include\xutility(3364) : see declaration of 'std::max'
    1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxdesktopalertwnd.h(81) : error C2782: 'const _T

    C / C++ / MFC c++ help csharp database visual-studio

  • Reading from and writing to the registry in windows Vista
    S Sternocera

    Bob, Thanks for that, but all I want to do is stored some key:value pair application settings! Surely there is a simpler way?

    bob16972 wrote:

    You need to include a security section in your manifest file to prevent Registry and File Virtualization for your application (or have the user turn User Access Control [UAC] off).

    Why? I thought that registry and file virtualisation where ways in which Vista supported applications that used the registry. Regards, Sternocera

    C / C++ / MFC question c++ windows-admin

  • Reading from and writing to the registry in windows Vista
    S Sternocera

    Hello, I'm maintaining an MFC application that reads and writes from/to the registry. Previously, it used the HKEY_LOCAL_MACHINE key. However, this meant that Vista users needed full OS administrative privileges, (and perhaps non-admin XP users, but there aren't a whole lot of those around) which isn't desirable. So, I changed the key used to HKEY_CURRENT_USER. This just appears to not work at all on Vista as a regular user, though it does work elsewhere. How can I store values in the registry without administrative privileges? Regards, Sternocera

    C / C++ / MFC question c++ windows-admin
  • Login

  • Don't have an account? Register

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