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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
R

Richard Ellis

@Richard Ellis
About
Posts
16
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Digital Camera Advice
    R Richard Ellis

    I second that. Easy to use and powerful, with enough bells and whistles to be more than just a point and shoot camera. Quality is excellent and of course those you do stuff up you just delete. In 6 months I have taken nearly 5000 photos - predominantly of my kids :) I have been luck enough to capture some magic photos of my kids! Only thing it lacks is a flip out screen. If you can afford one then consider getting it. Occassionally outside the screen can be a little hard to see - the flip screen doesn't have this problem. Checkout all the sites mentioned above, they are an excellent resource. Richard.

    The Lounge question

  • MSChart labels
    R Richard Ellis

    G'Day Rui, I'd forgotten all about this! I'll dig out the code I was playing with at the time and try it out. Thanks for your help! Richard.

    C / C++ / MFC help tutorial question

  • excel automation, hprocess is not closing
    R Richard Ellis

    G'Day Win, I use the same code successfully. What I discovered was that as I developed the application I would run it and terminate it prematurely with Excel open. This of course did not close down excel properly. So that when I started the application again I had 2 versions of excel running etc. Thus when I had a 'real' excel application running and I tested my program and shut excel down this code failed because I had closed down a different excel to the one being watched. I think this is what may be happening in your case. So terminate all excel processes with task manager, run excel and then your application and see if it works then. Hope that is of some help, Richard.

    C / C++ / MFC c++ com testing tools help

  • MSChart labels
    R Richard Ellis

    G'Day Anon I may have the answer for you though I'm not 100% sure because I'm yet to get it working myself - but I have run out of time for the moment. using the example on code project I have added the following code when the GO button is pressed. I have placed it just before the chart is refreshed. The first bit sets the legend (only did 1 to see if it worked) CVcPlot Plot = m_Chart.GetPlot(); CVcSeriesCollection SeriesCollection = Plot.GetSeriesCollection(); CVcSeries Series = SeriesCollection.GetItem(1); Series.SetLegendText(_T("New Text")); The next bit was to do the labels for each point on the axis. It is incomplete and not quite working but hopefully it will give you an idea and you can let me know how to fix it :-) I am getting a bad function argument error when calling SetColumnLabel or SetRowLabel - something to do with my indexes I think. CVcDataGrid DataGrid = m_Chart.GetDataGrid(); short i; CString strLabel; short nRows = DataGrid.GetRowLabelCount(); short nColumns = DataGrid.GetColumnLabelCount(); /* for (i=0; i

    C / C++ / MFC help tutorial question

  • system reboot
    R Richard Ellis

    G'Day Sergio, A while ago I wrote a NT Service that would reboot my pc. As suggested by Mauricio I used InitiateSystemShutdown. If you want the pc to reboot rather than shutdown then the last parameter should be TRUE rather than FALSE in Mauricio's example. With respect to priveleges - SE_SHUTDOWN_NAME is the only one that I have used. Good Luck Richard.

    C / C++ / MFC question json help tutorial

  • claiming focus for a dialog
    R Richard Ellis

    No, not until 30 seconds after you suggested it Nish :-) I missed that one. It now works like a charm. Thanks Nish problem solved! Richard.

    C / C++ / MFC c++ help

  • claiming focus for a dialog
    R Richard Ellis

    G'Day All, I have created a Dialog application that will manipulate some excel spreadsheets. In my OnInitDialog function (I am using MFC) I perform a test to see if excel is currently running. If it is running I display an interim modeless dialog that politely informs the user to shut excel and waits for them to do so (done with a call to WaitForSingleObject if that is relevant). This is all fine. Once excel is closed then I close this interim dialog and my OnInitDialog function completes and my 'real' dialog is displayed. However my problem is that when my 'real' dialog is displayed it is done so without the focus - it is not the currently active window. I have tried numerous things such as SetActiveWindow(), BringWindowToTop() etc without success. I was wondering if anyone could suggest a way of having my 'real' dialog start with the focus as it normally would if I wasn't mucking around with other windows whilst it was starting. Much Thanks In Advance Richard.

    C / C++ / MFC c++ help

  • Tricky NT Service Question
    R Richard Ellis

    Thankyou very much Gentlemen for your replies. That was enough to get me searching for a few things I had not thought of. I ended up coming across an article in MSDN that showed me how to create a process from with a NT Service. It seems to work well. FYI my code is below STARTUPINFO si; PROCESS_INFORMATION ProcessInformation; si.cb = sizeof(STARTUPINFO); si.lpReserved = NULL; si.lpTitle = NULL; si.lpDesktop = "WinSta0\\Default"; si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L; si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; si.lpReserved2 = NULL; si.cbReserved2 = 0; if (CreateProcess(NULL, "some exe name", NULL, NULL, FALSE, 0, NULL, NULL, &si, &ProcessInformation)) { LogText(" process created"); CloseHandle(ProcessInformation.hProcess); CloseHandle(ProcessInformation.hThread); } else { LogText("CreateProcess failed. Error %d\n", GetLastError()); } Richard Ellis.

    C / C++ / MFC question help discussion learning

  • Tricky NT Service Question
    R Richard Ellis

    G'Day All I am writing an NT service that uses some MAPI stuff. According to MSDN (and experimentation) it seems that must run without a desktop. Which is fine and indeed I have that part working. However I would like to add some functionality to this service such that it needs to interact with the desktop - specifically I would like it to manipulate the system tray. Now I believe that system tray manipulation needs a handle to a window but my problem is because the MAPI stuff requires no desktop I don't know how I can grab one. I had tried to enumerate child windows until I found the one I wanted but of course because there is no desktop that call returns no windows. So I was wondering whether anyone had a good idea as to how best to get around this? Is it possible to have the service start another exe/process/thread to do the manipulation which would have access to the desktop but not place a button on the task bar.... Much thanks for your thoughts, Richard Ellis.

    C / C++ / MFC question help discussion learning

  • Accessing Excel Cells from Visual C++
    R Richard Ellis

    G'Day Havoc, You should be able to find enough information in MSDN to get you going. Here is one link to a few articles http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno97ta/html/msoautovc.asp failing that try searching with the key words 'excel' and 'autmation' Good luck Richard.

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

  • Interprocess interacting
    R Richard Ellis

    G'Day Morozov I used this article to get me started when I had to do the very same thing. http://www.codeproject.com/system/cntservice.asp. Ended up creating an NT service and a Dialog Application to control the service, modify parameters etc. The above article was a huge help - thanks PJ Naughter :)

    C / C++ / MFC sysadmin help question

  • Folder/File Size?!?
    R Richard Ellis

    G'Day Greven, Maybe I have mis-understood what you are trying to do but you can use CFindFile to recurse sub directories. CFindFile has a member function GetLength() which returns the size of a found file. So it is easy to step through a directory and work out its size something like will come close (cut and pasted from existing code so I may have chopped some bits out but you should get the drift) TraverseDirectory(CString strDirectory) { int nBytes = 0; BOOL bWorking = finder.FindFile(strDirectory); while (bWorking) { bWorking = finder.FindNextFile(); strFileName = finder.GetFilePath(); if (finder.IsDirectory()) { if (!finder.IsDots()) TraverseDirectory(strFileName); } else { nBytes = finder.GetLength(); } } You can also use GetDiskFreeSpaceEx to determine free space information. Hope that helps. Richard.

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

  • [VC++]Create Excel sheet
    R Richard Ellis

    G'Day Samprayoga I was doing something similar just last week. There are a heap of knowledge base articles I found about this. Q179706 was the one I started with. From memory it has links to a more. Alternatively searching MSDN for 'office automation' should yield enough useful articles to get you started. Good Luck! Richard.

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

  • Office Automation
    R Richard Ellis

    Thanks for the prompt responses Christian and Masaaki I had feared as Christian suggested but Masaaki's post got me to looking further. I eventually came across Q189265 which listed some Microsoft Graph constants. Then it said "you can see the constants available with Microsoft Graph by using the OLE - Com Viewer that is available with VC++ in the Platform SDK." So I did and after a bit of searching I found the constants I was after. Thanks again for the suggestions :) Richard Ellis

    C / C++ / MFC question testing tools help tutorial

  • Office Automation
    R Richard Ellis

    I am have just started to teach myself about how to automate Office etc. I have found some knowledge base articles and am working my way throught them. Presently I am looking at Q179706 which talks about automatind Excel. About 30 or so rows into the sample code in the article is the following code snippet //Format A1:D1 as bold, vertical alignment = centre range = sheet.GetRange(COleVariant("A1"), COleVariant("D1")); font = range.GetFont(); font.SetBold(covTrue); range.SetVerticalAlignment(COleVariant((short) -4108)); //xlVAlignCentre = -4108 range is of type Range and sheet of type _Worksheet My question is this, how am I supposed to know xlVAlignCentre = -4108? I have searched files on my pc and MSDN for a definition or reference to where it is declared but turned up zip. I have found references to xlvAlignBottom etc on MSDN but nothing to tell me where they are stored or what their value is. Can anybody help? Thanks in advance Richard Ellis

    C / C++ / MFC question testing tools help tutorial

  • ? Strange print behaviour
    R Richard Ellis

    Firstly thanks to all who maintain and contribute to this site. I have learnt a lot from your efforts, so thanks again. Now to my problem. I have an application that is required to print some reports. I have done this by deriving a view from CView and using the MFC framework to do the printing for me. I have overwritten OnPreparePrinting, OnPrepareDC, OnBeginPrinting etc. Now everything has been working fine for quite a while now. Yesterday I came to do some minor modifications to the format of the report. I recompiled my application in debug and stepped into my code. I got an assertion failure in ...\mfc\src\viewprnt.cpp. It occurs in the function DoPreparePrinting(). pInfo has been created using default values etc - I don't try and do anything with it. I won't copy all the code for the function in here but basically it is an if..else statement. My code executes the else statement and I have marked the bit that fails. else { // otherwise, bring up the print dialog and allow user to change things // preset From-To range same as Min-Max range pInfo->m_pPD->m_pd.nFromPage = (WORD)pInfo->GetMinPage(); pInfo->m_pPD->m_pd.nToPage = (WORD)pInfo->GetMaxPage(); if (pApp->DoPrintDialog(pInfo->m_pPD) != IDOK) return FALSE; // do not print } ASSERT(pInfo->m_pPD != NULL); ***** ASSERT(pInfo->m_pPD->m_pd.hDC != NULL); **** This fails if (pInfo->m_pPD->m_pd.hDC == NULL) return FALSE; Now the things that bother me are that it worked in the past but not now. I have not changed the code that produces the report - only a small cosmetic change the the layout of the report. And further if I execute the program rather than step into it it works! I have done my best to wade through the documentation hand have searched the MSDN site and read the references I could find. I have stepped through this repeatedly and am most puzzled. From looking at the code in CView I can see that pInfo->m_pPD->m_pd.hDC seems to be created when CreatePrinterDC is called. However as I step through that statement is never called - it is in branches of code that my application doesn't execute. I don't really want to change what the user sees because I do want them to be able to change the default printer used. I have tried cutting and pasting CView's DoPreparePrinting function and inserting a CreatePrinterDC call but all this leads to is a crash when CView later on calls GetPortName because the pointer returned by ::GlobalLock(hDevnames) is NULL. If anyone has any ideas as to what might have happened

    C / C++ / MFC c++ debugging 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