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
M

montiee

@montiee
About
Posts
20
Topics
9
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Static variable in c/c++
    M montiee

    file1.c ------- int counter = 1; file2.h ------- extern int counter; file2.c --------- #include "file2.h" void countToTen() { while (counter <= 10) { printf("%d\n", counter++); } } Notice that counter is defined in the file.c file hence to access it we need to define it as external to our file2.c file that uses it. Hope that gives you an idea about extern vars. Similar principle applies to extern functions. You really need to read some books on the topic.

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

  • Automatically appending an auto incrementing build number to Apps title in Visual Studio 2009..? [modified]
    M montiee

    Thanks though I would prefer something a bit easier though. Interesting idea though. I might just write a little app that increments a build number in a .h file and call that per compile. Then include that in the app for use. Shouldn't be too hard. I'm amazed MS after all these years hasn't provided what is a fundemental tool for any developer releasing images for testing.

    C / C++ / MFC c++ csharp visual-studio com windows-admin

  • Static variable in c/c++
    M montiee

    Technically "x" isn't an extern the way you've done it. You don't need the extern keyword in file2.cpp. Extern is meant to imply that the variable is defined externally to the files that are referencing it. Since you've defined x in the header and then included it it isn't defined externally. Also you aren't using any static variables whatsoever in the example you've provided. I think you really need to find a basic C primer on the net talking about extern and static variable and read through that since you are missing some fundemental understandings. No point writing code until you clear that up.

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

  • Automatically appending an auto incrementing build number to Apps title in Visual Studio 2009..? [modified]
    M montiee

    Does anyone have instructions on how I would go about automatically adding an auto-increment build number each time the app is compiled so that it shows up in the apps titlebar? For eg say I have an app called Browser. First time I compile my app the title would be Browser V1.0 (build 1). I compile it again and it would be Browser V1.0 (build 2) etc. I don't want to have to manually go into the dialog editor and change it for each compile and neither do I want to have to update a variable by hand each time for compile. Any help would be appreciated. The language is VC++ and I'm using Visual Studio 2009. Thanks! PS: I'd like something that doesn't require me to alter or add stuff to the registry. I want to be able to grab the project folder, copy it to another machine and have it work straight off the bat without going through registering 3rd party dll's in the registry each time I move the source code to another PC. I found http://www.codeproject.com/KB/cpp/autobuildnumber.aspx but don't like the fact I need to go through a setup procedure that goes outside of the compiler. Also most discussions about the topic date back 6+ years. I'm hoping MS added some functionality into VS2009 to maybe make the process simpler, more native.

    modified on Sunday, October 5, 2008 8:05 AM

    C / C++ / MFC c++ csharp visual-studio com windows-admin

  • managed code strange behaviour..
    M montiee

    Never mind. I meant CLI integration with .net etc. In any event I ripped out the CRT requirement I imposed on myself by using MS's .net crypto services, in so doing nearly halfed my executable size and replaced the functionality with some native C++. In the end the problem wasn't what I thought. I tracked it down to one uninitialized variable. For whatever reason in the IDE it ran fine but outside it didn't. The wonders of random variable values..

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

  • managed code strange behaviour..
    M montiee

    I have a MFC app, within it I use SHA1CryptoServiceProvider() which is managed code. Now if I launch the app from within the IDE (via F5) it all runs nicely. However if I open up explorer and launch it through that it seems all my SHA1 calculations (computeHash()) fail. Everything else about the app works as expected except the hash checking. I'm taking a guess here but I'm almost certain it has to do with integration of unmanaged and managed code. Why is launching it from within the IDE so different than launching it outside of the IDE. What am I missing? Have I forgotten to load something (dll?) that gets automatically loaded from with the IDE. Any help much appreciated. I'm completely stumped.

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

  • dotted ip address to name?
    M montiee

    Thanks I missed the gethostbyaddr(). I used getnameinfo() since gethostbyaddr is deprecated and it worked out fine. Thanks for your help!

    C / C++ / MFC sysadmin algorithms json help question

  • dotted ip address to name?
    M montiee

    I'm currently coding a server and accepting incoming connections using the CAsyncSocket class under Vista. Things are working fine but now I would like to be able to resolve the dotted IP address CAsyncSocket::GetPeerName() returns into a nice human readable name so users can easily identify connections rather than remembering strings of numbers (dotted ip's). Can someone point me to the API which will help me do that. Spent a while searching but everything talks about going the other way, that is name->dotted ip, not dotted ip->name. Thanks!

    C / C++ / MFC sysadmin algorithms json help question

  • How to stop PC suspending or sleeping while app is running..
    M montiee

    Thanks for the pointers. I did end up using SetThreadExecutionState() as I really didn't need the fine control WndProc and it's power handling functionality offered. Nice and easy. Cheers!

    C / C++ / MFC json tutorial question

  • How to stop PC suspending or sleeping while app is running..
    M montiee

    Can anyone tell me the API I can use so that while my app is running it doesn't allow the OS to go into sleep or suspend mode? What must I do. Thanks!

    C / C++ / MFC json tutorial question

  • rand() always returns 18467...whats going on.. [modified]
    M montiee

    Thanks. That did the trick.

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

  • rand() always returns 18467...whats going on.. [modified]
    M montiee

    For the life of me I can't work this out. In the "apps" InitInstance I seed the random number generator by calling srand(time(NULL)); Then in a thread whenever I invoke rand() and print it out via cout it always has the value of 18467. Now rand() is invoked every minute or two so it's not like it's in a tight loop or anything like that. I never call srand again either. Just the once in the apps InitInstance function. Anyone experienced this problem before? Currently using Visual Studio 2008. I even went so far as to apply SP1 to it just incase something was fixed. Such a simple thing not working is really annoying me. Just to add if I print out rand() a few times in the apps InitInstance it works as expected. However once I call it from a UI thread it's always the same number.

    modified on Monday, September 1, 2008 3:30 PM

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

  • TimerQueueTimers..A question..
    M montiee

    Mark Salsbery wrote: No! You are responsible for cleaning up any resources associated with the user param if necessary. That's what I feared. So how does one delete the parameter one supplied at timer creation. Surely we don't have to keep track of a map that maps handles to parameters to delete?! I'd be interested in hearing a confirmation that I need to keep track of it all myself but in the meantime I'll start making the changes to keep track of it because I have a feeling that's the way it's headed. It's be nice if the documentation mentioned these things..

    modified on Monday, September 1, 2008 3:29 PM

    C / C++ / MFC question c++

  • TimerQueueTimers..A question..
    M montiee

    I'm using the timerqueuetimers that MFC provides in my app. No problems at the moment with them but I do have one puzzling question I can't answer. With TimerQueueTimers you are allowed to supply context or user specified data as a parameter which can be used when the callback gets invoked. Now if I want to stop the timer (ie delete it) I call DeleteTimerQueueTimer(). All well and good but how do I delete any user data I've attached as a parameter when I created the timer? The documentation says nothing. Does it automatically delete the parameter? Appreciate any input.

    C / C++ / MFC question c++

  • WinHttp help with Request Headers Pls..
    M montiee

    Meh, for the record I've convince myself that there is no way to remove the "Connection" request header in winhttp since I can remove any other header so it seems the winhttp forces this header to exist whether you like it or not. Damn stupid but what can you do. Going to port over to winiinet (3rd times a charm) which I think doesn't have this braindamaged idea that it knows better than I what I want.

    C / C++ / MFC help announcement

  • WinHttp help with Request Headers Pls..
    M montiee

    I've nearly got everything working in my bit of code but I want control over what Request headers I send. I can add Request headers via WinHttpAddRequestHeaders() but for whatever reason I cannot get rid of one Request header. I would like the "Connection: Close" header to just never exist (ie remove it completely) in the HTTP stream that I send. To this effect I thought the following bit of code would work WinHttpAddRequestHeaders(hRequest, L"Connection: Close", -1L, WINHTTP_ADDREQ_FLAG_REPLACE); I tried many variations of just "Connection" or "Connection: " etc and none of them seem to get rid of the "Connection" Request header. I think I did a decode of the error and it says the header does not exist. However when I fire up my packet capture program sure enough it's there. Any help or pointer to what I'm misunderstanding would be greatley appreciated. I trawled this site and the net and couldn't find anything. PS: I had no such problem with this using CInternetSession etc in my old version of the code but unfortunately I need control over timeouts and retries etc and these functions have had it broken so I resorted to winhttp hoping for something better. Cheers Jbem

    C / C++ / MFC help announcement

  • Help adding toolbar to a propertypage!
    M montiee

    Well I have a mini-project just for my own personal curiosity where I've setup a propertysheet and added a number of propertypages to it. So far so good, no issues. However on on of the propertypages I want to add a toolbar. Now there is quite a bit of info out there on toolbars but for the life of me I can't work out what I'm missing so I'm hoping one of you might point me to some source code where this is done or point out what I'm missing. Below is the code I added to add the toolbar to what I think should be the property page. int CClientMgrPage::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CPropertyPage::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here CFrameWnd *pFrameWnd=(CFrameWnd *)GetParent(); if (!m_CMgr_ToolBarCtrl.CreateEx(this, TBSTYLE_FLAT, WS_CHILD|WS_VISIBLE|CBRS_TOP) || !m_CMgr_ToolBarCtrl.LoadToolBar(IDR_Emgr_TOOLBAR)) { TRACE0("Failed to create Client Mgr Toolbar"); } m_CMgr_ToolBarCtrl.EnableDocking(CBRS_ALIGN_ANY); pFrameWnd->EnableDocking(CBRS_ALIGN_ANY); pFrameWnd->DockControlBar(&m_CMgr_ToolBarCtrl); return 0; } With this code in place I trigger an assertion when I click on the tab containing the Toolbar. CDockContext::CDockContext(CControlBar* pBar) { ASSERT(pBar != NULL); ASSERT(pBar->m_pDockSite != NULL); <------- } Any ideas?

    C / C++ / MFC database help question workspace

  • MFC Serialization Questions..
    M montiee

    Thanks ToxickZero. Same solution as Ravi offered also and works fine as I just implemented it. Pity you need to keep track of the number of elements when serializing. Wish it could be done in a more dynamic fashion but it seems as it is not to be.

    C / C++ / MFC c++ json question

  • MFC Serialization Questions..
    M montiee

    Thanks Ravi. I initially saw these primers and had a bit of a read through all 3 of them so thanks for putting the effort in to write them up. The thing I have a problem and which I was trying to avoid was having to store the number of items in the actual file. It seemed rather logical to me that if you know the way you stored data for a class you should be able to serialize chunks which would automatically walk the file in the right increments via the archive buffer till EOF on deserialization. I guess not. So the thing I get out of all this is that if you have a list of objects of a type that you want to serialize then there is no other way than to store the number of objects as the first item if you ever want to recreate that list of objects ever again. I guess CArchive has no concept, that is exposed to the user, of file position based on what it has serialized just more like a buffer position internally.

    C / C++ / MFC c++ json question

  • MFC Serialization Questions..
    M montiee

    I'm sure the answer is obvious but I can't seem to work it out. I have a created a class (called Cemu) which is tagged as serializable via MFC's macros. Now in Cemu there consist a couple of CString's which I want to serialize. To complicate matters I have a list of Cemu entries stored in CemuList. What I have done when I want to dump the list to the file is loop through CemuList and call the serialize() method I created in Cemu which in turn writes out the CStrings I want to a file. That process seems to work just fine by examining the file afterwards. What I'm have trouble with is de-serializing. My initial stab at it is below but that doesn't work. while (file.GetPosition() < file.GetLength()) { client = new Cemu; client->Serialize(archive); CemulList.AddTail(*client); } The file containing the data has 2 Cemu serialised entries and what I'm finding is that only one gets read in. My interpretation was that the act of serializing the Cemu would move the file pointer along correctly, ie a total of 2 times but I'm missing something. Can point me in the right direction? Cheers!

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