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 Mares

@Peter Mares
About
Posts
19
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Socket funcions and IOCompletion port questions?
    P Peter Mares

    Hi, 1. Yes, and yes. 2. U should be using winsock2.h 3. IOCP sockets that support 'receiving data', should be in a constant state of 'being ready to receive data. Due to the nature of IOCP, the worker threads are the ones handling the events, so you don't want to use WASAsyncSelect/WSAEventSelect stuff. There are a couple of really good articles on CP for IOCP servers and sockets - you should have a look at them. Also, remember that if you have multiple buffers per socket (which you should have), you will not always be able to guarantee the sequence of partial packets received when you run on a multi-CPU box. Hope this helps a bit


    controlSHIFT [WinShareSpy] [Glossary Manager] [AfterThought Backup Lite] All good things were meant to be improved

    C / C++ / MFC question

  • ADO inside win32 services goes boom
    P Peter Mares

    Hey, thanks for the reply. I found the problem. When running under the SCM as a service, the SCM obviously takes the "entry point" nominated in the dispatch table that is passed into StartServiceCtrlDispatcher( ) and puts it into another thread. Since I was calling CoInitialize BEFORE this, COM never got initialized, or so it seemed. Simply putting CoInitialize into the entry point function sorted me out. As an aside, I am slightly curious why, before the fix, calls the ADO Connection::Open( ) function SUCCEEDED and the CreateInstance( ) function returned what seems to be a valid interface pointer to the Connection object - weird. Anyhow, atleast its sorted out :D Thanks, Peter


    controlSHIFT [Glossary Manager] [AfterThought Backup Lite] All good things were meant to be improved

    Database help database testing beta-testing question

  • ADO inside win32 services goes boom
    P Peter Mares

    Hi everyone, I've wondered across a peculiar issue with ADO (although something else could be the culprit, but through my investigation, I believe it to be ADO). I have written a service that uses ADO. When running the service as a console app, everything works great. However, when the service is run 'as a service' in the SCM, I find a problem with the connection. Basically, this is what I've found to happen: 1. I issue a connect() call, and it returns S_OK. 2. Immediately after that, I execute a simple query, say "select count(*) from table1". At this point, when running as a normal app, the query executes and all is well. However, as a service, the query fails. Upon further inspection, doing a check on whether the connection is actually "connected", I find that it is infact disconnected. Any ideas? I've been thrashing my brains with this problem for a few hours now. Maybe someone can shed some light on this? I have tried changing the account under which the service runs. That didn't work. I tried testing different data providers. Same problem. Anything else I can try? Thanks, Peter


    controlSHIFT [Glossary Manager] [AfterThought Backup Lite] All good things were meant to be improved

    Database help database testing beta-testing question

  • List box control
    P Peter Mares

    ok, to add columns to the list control, make sure that you create the control with the LVS_REPORT style. then call CListCtrl::InsertColumn() to add a column and then CListCtrl::InsertItem() to add items. I saw a post that already indicated this. Now to the problem of sizing the control to the size of your dialog: In the dialog class, handle the WM_SIZE message, call GetClientRect() to get the current client rectangle of the dialog and then just call CListCtrl::MoveWindow() to size the list control to the size of the dialog. HOpefully that explains it. Ciao


    controlSHIFT [Glossary Manager] [AfterThought Backup Lite] All good things were meant to be improved

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

  • List box control
    P Peter Mares

    Pazzuzu wrote: [1]How will I create a Listbox control used the "m_ListBox.Create"- How will I pass the cDialog class as I have to pass a "pParentWnd parameter" which expects a CWindow object All MFC windows (including CDialog objects) derive from CWnd. Just cast it to CWnd in the create function Pazzuzu wrote: [2]How to make the listbox control,Dialog & view class of the same size What do you mean? like as in the same size on the screen? Pazzuzu wrote: [3] Want to add 2 columns in the list box,a header row, with constant values You are using the wrong control. Use a CListView control rather. Cheers, Peter


    controlSHIFT [Glossary Manager] [AfterThought Backup Lite] All good things were meant to be improved

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

  • How to reposition Modeless Dialog box on resizing application window
    P Peter Mares

    If my understanding of your problem is correct, you are trying to use a modeless dialog to look as if its a "pane" within your application. If this is correct, read on: 1. Make the dialog a CHILD dialog 2. In the parent window, handle the WM_SIZE message and then merely resize the child dialog. For example (a WTL eg): void OnSize(UINT uiCode, CSize sz) { CRect rect; GetClientRect(&rect); if ( ::IsWindow(m_MyChildDialog.m_hWnd) ) { // do some manipulation on the rect if needed... rect.DeflateRect(10,10,10,10); // here I'm just decreasing the overall size of the rect m_MyChildDialog.MoveWindow(&rect); } } That should be all you need to do. Let me know if I've missed your question completely. Cheers, Peter


    controlSHIFT [Glossary Manager] [AfterThought Backup Lite] All good things were meant to be improved

    C / C++ / MFC question help tutorial

  • Printing question
    P Peter Mares

    Hey everyone, I'm busy working on a mini POS system, and they have an Epson LX400 printer that they use to print till slips. They feed a 7.5cm wide roll of paper through for the till slip. The problem arises when I use GDI printing and call EndPage(), the printer feeds the equivalent of an A4 page upwards. I've tried modifying the DEVMODE structure before I call CreateDC() but nothing works. How do I stop the printer from form feeding? The software needs to run on Win98, so I can't use AddForm(), GetForm() etc. Any ideas? Regards, Peter PS If I use standard fopen and fprintf functionality, everything is fine, but then I can't get the client's logo onto the slip, so thats not an option.


    controlSHIFT [Glossary Manager] [AfterThought Backup Lite] 99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    C / C++ / MFC help question graphics

  • What do you guys use to parse XML?
    P Peter Mares

    I deal with "simple" XML files, ie, no specific schemas etc.. so I also rolled my own parser and it saving and loading up of any XML file... The MSXML object is awesome, but on startup requires like 16 Mb of member immediately... so its resource heavy...


    www.kinkycode.com [Glossary Manager] [AfterThought Backup Lite] 99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    C / C++ / MFC c++ com xml question

  • Fonts and MFC
    P Peter Mares

    Try this: CFont tahomaFont; tahomaFont.CreatePointFont(120, "Tahoma"); // 12 pt * 10 YourCWndObject.SetFont(&tahomaFont); That should work. A really good idea is to store your font objects as member variables of a class so you can clean up after yourself at the destructor phase. Hope this helps


    www.kinkycode.com [Glossary Manager] [AfterThought Backup Lite] 99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    C / C++ / MFC tutorial question c++ com

  • ComboBox problems when moving...
    P Peter Mares

    Hi everyone, I have the following code that works GREAT except for when ComboBox controls are present... ::GetWindowRect(hWndChild, &rect); topLeft.x = rect.left; topLeft.y = rect.top; bottomRight.x = rect.right; bottomRight.y = rect.bottom; ::ScreenToClient( pData->pParentWnd->m_hWnd, &topLeft ); ::ScreenToClient( pData->pParentWnd->m_hWnd, &bottomRight ); if ( pData->uFlags & KCSB_ATTACH_LEFT ) { topLeft.x += pData->nOffset; bottomRight.x += pData->nOffset; } else if ( pData->uFlags & KCSB_ATTACH_TOP ) { topLeft.y += pData->nOffset; bottomRight.y += pData->nOffset; } ::SetWindowPos( hWndChild, 0, topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y, SWP_FRAMECHANGED | SWP_NOZORDER ); Ok, here is the scenario. At some point, that code will be executed to shift all child windows on a parent dialog up by a certain offset. Everything works great, and even the combobox's shift.. BUT If the combobox controls are shifted, they lose their ability to display their text in the contained edit control, they don't show their cursor (when focus is on them) and they don't show anything that is being entered into them (but they do store the data, and one can query the text programmatically). The drop downs work great tho ;) Any ideas? (I'm using MFC7 for this, but I don't think thats the problem...)


    www.kinkycode.com [Glossary Manager] [AfterThought Backup Lite] 99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    C / C++ / MFC help database com question

  • Just a bit of a brag
    P Peter Mares

    Not too long... a few days or so... :) As for the FAQ comment last on in this subthread... all I can do is just smile :))))


    www.kinkycode.com
    99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    The Lounge help com question announcement

  • Just a bit of a brag
    P Peter Mares

    I've release my first product under my kinkycode.com banner!! *smile* Hope the technical writers in the world find it useful ;) If you guys wanna check it out, click here Hope you guys had a cool weekend ;)


    www.kinkycode.com
    99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    The Lounge help com question announcement

  • CListCtrl advanced - loading
    P Peter Mares

    Why don't you use a virtual listview? This basically means that you only need to load the records currently being displayed.... I don't know off hand of an article on CP for this, but there is documentation in the MSDN...


    www.kinkycode.com
    99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    C / C++ / MFC help tutorial

  • Ali G does CP
    P Peter Mares

    This is just something I had to share with you guys & gals ;) http://alig.webdeznet.co.uk/?website=http%3A%2F%2Fwww.codeproject.com[^]


    www.kinkycode.com
    99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    The Lounge help com question

  • What about Qt?
    P Peter Mares

    How about a grounds up Qt tutorial... or a moving from MFC to Qt. The only thing I don't like about Qt is that if you want to create commercial applications, you have to buy the Qt library (which at the South African exchange rate is a bit hectic)


    www.kinkycode.com
    99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    The Lounge question learning

  • Copy a pointer to an element of an array of pointers
    P Peter Mares

    the line ClassA *ptr = new ClassA[5]; defines an array of 5 ClassA objects, not an array of 5 ClassA pointers. If you want an array of 5 ClassA pointers, your declaration will have to be: ClassA **ptr = new ClassA*[5]; and then you will be able to execute the following code (or similar): ClassA *ptr1 = somePointerOFClassA; ClassA *ptr2 = somePointerOFClassA; ptr[0] = ptr1; ptr[1] = ptr2; Now, coming back to your previously mentioned code block.Unfortunately, once you have defined an array as you have : ClassA *ptr = new ClassA[5]; You cannot actually change the address of an element within that array, ie, you cannot do this: &ptr[0] = ptr1


    Hope this helps some. Cheers, Peter ------------------------------------------- 99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

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

  • How to print an ATL 3.0 based Active X
    P Peter Mares

    What I can suggest is this. The GM_ADVANCED flag is not supported in anything below Windows 2000, so first, get your OnDraw() function to check if you're drawing to an old style metaDC. You can do this like this : bool bMetaDC = false; if ( GetObjectType(hdc) == OBJ_METADC ) bMetaDC = true; Now that you know that you're rendering to an old metaDC, create another DC, do all your drawing to that and then BitBlt() to your metaDC. I don't know if it will work, but its worth a try... ------------------------------------------- 99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    ATL / WTL / STL help c++ com hosting algorithms

  • How to print an ATL 3.0 based Active X
    P Peter Mares

    Ok... heres to solution to getting your ATL components to print from within Office Applications. It seems as if Office Applications still use the old 16bit Metafile format when printing. This is a problem because it limits you to using only the GDI functions that are supported by the old Metafile DC. For a list of functions that you CAN use, see this Microsoft document. I've rewritten all my drawing code to support these functions and my control is printing fine ;) Should work for yours aswell. Thanx to Microsoft for documenting this little issue so nicely *sarcasm* :P Cheers, Peter ------------------------------------------- 99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    ATL / WTL / STL help c++ com hosting algorithms

  • How to print an ATL 3.0 based Active X
    P Peter Mares

    Hi, I've written a simple ActiveX control using ATL 3.0 ... and everything works fine... until I want to print the document that is hosting my control. In this case, its Excel. Everything on the excel sheet prints EXCEPT my activeX control. What am I missing here? Any ideas? I've tried searching online, in MSDN, etc etc... nothing. Any help would be greatly appreciated... :) Thanx ------------------------------------------- 99 little bugs in the code, 99 little bugs, Fix 1 bug, recompile.... 101 little bugs in the code...

    ATL / WTL / STL help c++ com hosting algorithms
  • Login

  • Don't have an account? Register

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