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
K

Kayembi

@Kayembi
About
Posts
81
Topics
39
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Rebar - toolbars overlapping problem
    K Kayembi

    P.S. Depending on what version of comctl32.lib you are using, you may have to change MIIM_STRING to MIIM_TYPE to get main.cpp to compile - or just comment out the whole of CreateMenu() as it has nothing to do with my toolbar problem anyway. Any replies or help much appreciated! Many thanks, KB

    C / C++ / MFC c++ help com debugging json

  • Rebar - toolbars overlapping problem
    K Kayembi

    Hi, I am struggling to create a decent-looking toolbar using the Windows API with no MFC (it may well be easier with MFC if you know it, but I have yet to plough through my MFC books and I don't want to port the whole of my nearly-finished current project). After struggling for a couple of days to get a 'flat' look (using TBSTYLE_FLAT) without having all the buttons become transparent, I discovered that to get the look I wanted, I needed to use Rebars. I used the code from MSDN (here) to create a test rebar, and it gave me the look I wanted - except that it is still screwy in another way (probably because MSDN assumes two other functions that it doesn't provide - CreateToolBar() and CreateComboBox()). Essentially, I want two rows of toolbars, so I figured that I would need to create two toolbars and two 'bands' in my rebar to hold them (ie. two calls of RB_INSERTBAND with the RBBS_BREAK style. I have successfully set up my test proggy so that it has two bands of the correct size, but the problem is that the toolbar buttons that should be on the second band aren't in the right place - they overlap the toolbar buttons on the first band (ie. both toolbars seem to have been created at window co-ords 0,0). I can better explain what I mean by posting a picture: Picture Here The CPP file for this test proggy can be downloaded here - this is the only file of the project, so can be compiled to the test prog. It's messy because it's just a test program that I threw together to try and get rebars and toolbars working. CreateRebar() was ripped from MSDN, with only minor modifications. The problem might be there, or it might be in CreateToolBar() (which creates a toolbar with three text buttons) or CreateToolBarIcons() (which creates a toolbar with some standard Windows buttons). I've stared and stared, experimented, tested and generally poked around, but I just can't see what I'm doing wrong. If anybody has a chance to scan these functions to see what my mistake is, or just make some suggestions as to what you might think the problem could be, I would really appreciate it. Obviously I don't expect anybody to debug my code - I only attach the CPP file because it is easier than posting three long functions here. Many thanks to anyone who can help, KB

    C / C++ / MFC c++ help com debugging json

  • Access - changing database password from an EXE
    K Kayembi

    Hi, I need to write a small program that backs up a Microsoft Access database in a specific way, and wondered if anybody here could offer me a little help. Basically, this is what the program needs to do: 1) Copy the original database (.mdb file) to a different folder (the backup folder). 2) Change the database password of the backed up version (the backup needs a different password). 3) Set the properties of the backed up password to "Read-only". 1) and 3) are easy, but 2) is giving me problems. At the moment I have to do this manually at the end of each day - by opening the copy using "Exclusive access", unsetting and then resetting the database password. Essentially I just want to write a program to automate this process and save me time at the end of each day. I am hoping that there is some way to automate step 2. If this is a really basic question, please accept my apologies. I have written a few basic C/C++ and WinAPI programs, but I have never interfaced with Access from another program. Many thanks for any help or pointers, KB

    C / C++ / MFC c++ database help question announcement

  • Making the transition from Win API SDK to MFC
    K Kayembi

    Thank you for your reply, it's very encouraging. At first I was scratching my head to your answer to question 4, before I realised that SDI is just "Single Document Interface" (as opposed to MDI) - just the terminology can be daunting at first. :) Everyone seems to recommend the Prosise book, so I think I am going to splash out and buy both, so I can use Prosise's as a reference. Looking through the indexes (indices?) on Amazon.com I see that Prosise's book covers such things as RTF files and tree views, so I can turn to that once I've gone through the basics in Jones and am ready to take on the main aspects of my program. Thinking about your reply to no. 2, I have decided to go through some C++ basics before looking at these books though. I have just bought a very nice and cheap book called "Teach Yourself C++ in 10 minutes" (somewhat ridiculously) by Jesse Liberty. I've started going through it and I really like it, as it recaps on the basics of C and then moves into very short (supposedly 10 mins each) lessons on C++ - OOP, classes, etc. I like it because it means I can grasp the bare basics of some of the C++ concepts without having to wade through 1,000 pages (nothing worse than slogging through a book and thinking "I'm not going to learn how to use a class until page 600, and I'm a slow reader..."), and I can refer to my other C++ books with a more need-to-know approach after I've got some of the concepts (and terminology - one of the problems of being self-taught) pegged. It's very encouraging to hear that someone else has taken a similar route when learning MFC. Thanks again, KB

    C / C++ / MFC c++ question learning data-structures json

  • Making the transition from Win API SDK to MFC
    K Kayembi

    Hi, I am thinking of making the transition from using the Windows API SDK with mostly C to MFC - well, more than just thinking, I really want to do it. I have been using the Windows API and learning C with a modicum of C++ for the past couple of years, and have created several small programs (with a lot of help from the kind people here), but now I want to take it a stage further. I have an idea for a Windows program that I'd like to make as professional as possible with a nice GUI, and I think that MFC is the way to go for two reasons: Firstly, given that my program is designed to look a little like a cross between Explorer and a word processor, with a tree view on the left and a rich edit box on the right in a dockable window, I can easily generate the basic GUI of my program using appwizard. Secondly, there are a lot more code examples, both here and elsewhere, that would be very useful for my program that use MFC than the SDK, and so far I have spent a lot of unnecessary time struggling to convert code from MFC to straight C/WinAPI. That's the waffle over, then. Considering that I learn much more easily if I am motivated by a goal (in the case the goal is the software I want to write) rather than by following dry tutorials which teach me how to write small programs I'll never use, I'd really appreciate some tips or advice on where to start with making this transition: 1) I know this is a question that comes up a lot, but what books would people recommend to help me make this transition? Before you shout: I have searched this forum, the FAQ and elsewhere, and the two books that seem to come up the most are Richard Jones's 'Introduction to MFC Programming', and Jeff Prosise's 'Programming Windows with MFC'. I am thinking of buying the Jones, because I am not very familiar with OOP and this is supposed to be easier as an introduction. Is this a good way to go? Or are there other books I may have missed? 2) I am guessing that in order to learn MFC I am going to need to improve my knowledge of C++ drastically - like I say, aside from some limited use of classes, I have mostly used straight C so far. I have the SAMs book by Jesse Liberty, which I am returning to right now, as well as other books which are way out of my league (I don't think I've ever opened my Stroustrup :) ). Should I learn more C++ before turning to MFC? Or can I learn what I need to know about classes and OOP as I go along whilst learning MFC? And if so, are the books above helpful for this too? 3) As a quick test, I tried usi

    C / C++ / MFC c++ question learning data-structures json

  • RichEdit with Treeview - associating and saving
    K Kayembi

    Hi, I am currently working on a small app that I hope to make partly a combination of a basic word processor with an Explorer-like tree. Thus, on the left there is a tree view and on the right there is a Rich Edit box. The tree view represents virtual "documents" in a virtual filing system. By clicking or right-clicking in the tree view, you can select or create a new virtual document. The currently selected document should be shown in the rich edit box on the right, which can be typed from scratch or edited etc. I am using the straight Windows API SDK with _no_ MFC, and I am still a relative novice code - after a few small apps, this is my first attempt at writing a piece of software I would really like to use, so please forgive me for asking basic design questions, but here goes: 1) What is the best way of associating the text in a rich edit box with a tree view item? I was initially thinking of associating a string (Rich Edit) with an HTREEITEM, as I have used this method before, eg: HTREEITEM tr1, tr2, tr3; char* str1, str2, str3; if(tree_item_selected == tr1) { ShowRichEditText(str1); } ..er, etc. Obviously, though, this is fundamentally flawed as it would mean that there would have to be a limit to how many HTREEITEMs -and therefore documents - the user could create. In other words, I would have to create a set (large) number of strings, and the same number of HTREEITEM pointers to use this method. I would probably have to create a thousand strings or HTREEITEMs or so to make sure the user didn't run out. Could someone please suggest a better way of doing this? In essence, I just need to be able to associate an arbitrary number of strings containing RTF text with an arbitrary number of HTREEITEMs. Sorry if this is a fairly stupid question. 2) If (1) is achieved, how would I then save it to file? Would I be able to save the info as a struct or some such and just use CreateFile() and WriteFile(), or would I need something more complicated to hold this sort of info? Many thanks to anyone who can give me some tips, pointers, or directions to non-MFC examples, and even more thanks to all those who have put up with my newbie questions and given me help over the past couple of months. :) Cheers, KB

    C / C++ / MFC question c++ design data-structures json

  • Saving multiple RTFs to string for storage?
    K Kayembi

    Hi, I'm writing a program that incorporates a Rich Edit control text editor containing consisting of an arbitrary number of "documents". On the left of the screen is a tree view, and on the right of the screen is a rich edit control for text editing. The user uses the tree view to create new "documents". By clicking on a tree view item, the document that that represents should appear in the rich text control on the right. All of this has to be saved to a single file (possibly using structs), and exported to an RTF. Saving to RTF is sorted (thanks to help from users here), but my problem is this: How can I save an entire "document" to a string? I have tried saving to a char*, but I haven't got it working. Note that I am using _no_ MFC, and I am not a very experienced programmer - I am still on a steep learning curve, so please forgive any idiocy in my code. This is what I tried: char* szTextTest; long nTest; static DWORD CALLBACK MyStreamInStringCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { memcpy(pbBuff,szTextTest,nTest); *pcb = cb; return 0; } void LoadRTFFromString(HWND hWnd, int nIDDlgItem) { EDITSTREAM es; es.pfnCallback = MyStreamInStringCallback; SendDlgItemMessage(hWnd,nIDDlgItem,EM_STREAMIN,SF_RTF,(LPARAM)&es); } static DWORD CALLBACK MyStreamOutStringCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { nTest = cb; szTextTest = new char[cb]; memcpy(szTextTest,pbBuff,cb); *pcb = cb; return 0; } void SaveRTFToString(HWND hWnd, int nIDDlgItem) { EDITSTREAM es; es.pfnCallback = MyStreamOutStringCallback; SendDlgItemMessage(hWnd,nIDDlgItem,EM_STREAMOUT,SF_RTF,(LPARAM)&es); } Even if I could get the above working, would I be able to save the character pointer, szTextText, to file using WriteFile() and have it save all the text it has been allocated? I have only ever saved structures containing chars that aren't pointers to file so far... If I can copy the whole of a formatted RTF file to a string, this is what I am thinking of doing to save the structure: For each folder, copy text into the string such as "{{folder:name_of_folder;}}" or some such, and then add to the end of that the rich text that is associated with that folder. When reloading from file, I just need to search the string for occurrences such as "{{folder::...}}" etc in order to rebuild my treeview and associate text appropriately. Thus the string created to hold the rich text needs to be infinitely long - or

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

  • EM_STREAMOUT and EditStreamCallback() function?
    K Kayembi

    Hi, Could someone please give me some tips - or even better, link ot some examples - on how to create an EditStreamCallback function? I have searched the net and several coding forums, but can't find any solid information, even MSDN. I have a Rich Edit text box, and whilst I can currently save to a .txt file using GetDlgItemText() and WriteFile(), this method is very limited and I really want to save as an RTF file. I have read the info on EM_STREAMOUT and EditStreamCallback, and it seems that these are the functions I need to use in order to save as an RTF file. If anyone can tell me how to write a callback function that will write an .rtf file, link to some more comprehensive info, or just give me some general tips, I would be really grateful. Incidentally, I am using the straight Win API SDK with _no_ MFC. Many thanks! KB

    C / C++ / MFC c++ json architecture tutorial question

  • Unlimited or arbitrary string lengths?
    K Kayembi

    Great, thanks for the info, and thanks for the replies to both of you. In the end I went the EM_GETTEXTLENGTHEX route and used that to create the buffer, though I had problems before realising that I needed to load RichEd20.dll instead of RichEd32.dll, and then, because I was using a dialog-based app, I had to manually change the class name in the .rc file to "RICHEDIT20A" instead of "RICHEDIT" (just in case anyone else encounters this problem). Thanks again! KB

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

  • Unlimited or arbitrary string lengths?
    K Kayembi

    Hi, I'm writing a small program with a basic text editor incorporated. It is basically a dialog box with a rich edit box and the capability of saving what is written in the rich edit box to a .txt file. Here is the function I am using to save the text (I'm using _no_ MFC, by the way): [code] void SaveRichEditText(HWND hWnd, int nIDDlgItem, char* szSaveFile) { char szText[100000]=""; GetDlgItemText(hWnd,nIDDlgItem,szText,100000); HANDLE hFile = CreateFile(szSaveFile,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); DWORD dwW; WriteFile(hFile,szText,strlen(szText),&dwW,NULL); CloseHandle(hFile); } [/code] This works fine, and the file is saved with the correct text. However, as you can easily see from the code, this has a severe restriction: the text that can be saved is limited to 100,000 characters (or any other arbitrary limit I choose for char szText[]). This is no doubt a very stupid and basic question, but I can't find the answer in my Sams or "C for Dummies" or other books, so please forgive the lack of knowledge of a relative novice: How do I make it so that the text length is not limited by the char? Is there a way to get the length of the text in the Rich Edit box and then create a string on the fly that is the length of this? I am sure I have seen somewhere a method using mem... commands, but can't find the answer. Once this is solved, I would then need to create a load command that reads the text from file using ReadFile(), and I will be faced with a similar problem - namely getting the length of the string from the .txt file and creating that string to insert into my rich edit box. If anyone can tell me how to go about solving these two problems, I would be really grateful - apologies again if this is a really basic question. Many thanks, KB

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

  • MoveFileEx not always working?
    K Kayembi

    Hi, thanks for the reply. This is the weird (and really annoying) thing - neither fail. I have checked their return values, and all is okay. And I have even checked the registry itself, and found that all the values are perfectly correct inside PendingFileRenameOperations, and everything seems fine. And yet still, sometimes when I reset the computer, nothing is deleted. At first I thought that it must somehow be falling through to the code at the end of my program which removes the entries from the registry if the files have been deleted normally after the program has closed, but I tried commenting this code out and it made no difference. This is really strange. Does anyone know of any reason why PendingFileRenameOperations in the registry might be ignored or just deleted at boot up without actually running? Many thanks, KB

    C / C++ / MFC database com windows-admin json help

  • MoveFileEx not always working?
    K Kayembi

    Hi, I have an app that uses MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT. The app basically extracts some temporary files from a .zip file to a cache directory. After each file is extracted, a delete on reboot key is added to the registry if the system is WinNT/2000/XP, otherwise WinInit.ini is used. If the program ends normally, the registry keys are deleted (or WinInit.ini is restored to its former state). The idea is simply that the cached files are cleaned up no matter how the program ends. However, there seems to be some bug whereby the files aren't always deleted on boot up. Strangely, sometimes they are, sometimes they aren't. I can't find any logic behind it, despite having tested it over and over again. In every case my code seems to be working fine, as I check the registry before rebooting and the PendingFileRenameOperations key contains all of the info that should be there (all the paths to the files I want to delete with \\?\ before them or whatever). When I reboot, the PendingFileRenameOperations key is gone - as though it has been executed - but the files are not always deleted. Very strange. This is the basics of the code I am using to do this: /* Extract all files in a .zip archive and set them up so that they should be deleted on reboot if the PC is reset while the program is running: */ //fileno = number of files contained in a .zip file: for (int currfile = 0; currfile < fileno; currfile++) { /* Zip extraction is handled by the library available from www.artpol-software.com */ //Extract the file: zip.ExtractFile(currfile,OutputPath_str); //extract file from .zip by index to cache dir //Set it up so that the file will be deleted if the PC is rebooted: /* EDITED: here I have some code that gets the file name and file path from the current zip index number, and stores the full path in a string, szCurrFile... (I know this is working, because it displays the correct info in the registry) */ //For each file, remove it if PC is rebooted: if(MoveFileEx(szCurrFile,NULL,MOVEFILE_DELAY_UNTIL_REBOOT)==0) { //Fall back to WinInit.ini... //here I have my fallback code using WritePrivateProfileSection() } SetFileAttributes(szCurrFile,FILE_ATTRIBUTE_HIDDEN); //Ensure window is updated if anything happens in the meantime: if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if(msg.message == WM_QUIT) { //If user destroys this program, skip to the end to clean up: GRS_quit = 1; //flag to tell rest of program to skip certain loops

    C / C++ / MFC database com windows-admin json help

  • Calculating window size based on bitmap and titlebar/border?
    K Kayembi

    Brilliant, thank you! Both suggestions work great, but I've used AdjustWindowRectEx because it requires less code... Thanks again, Keith

    C / C++ / MFC help graphics question

  • Calculating window size based on bitmap and titlebar/border?
    K Kayembi

    Hi, I have a program that generates a window depending on user settings. The window contains a bitmap that the user selects, and can have various border types (dialog, client edge, no border), and may or may not have a title bar. The window is supposed to be the size of the bitmap that is selected. However, I have just realised that my window size does not take account of the titlebar or border of the window. For instance, I calculate my window position and size like this currently: BITMAP BMPSize; HBITMAP SizeCheckBMP; .... GetObject(SizeCheckBMP,sizeof(BMPSize), &BMPSize); .... //center window in screen: xpos = (GetSystemMetrics(SM_CXSCREEN)/2)-(BMPSize.bmWidth/2); ypos = (GetSystemMetrics(SM_CYSCREEN)/2)-(BMPSize.bmHeight/2); //calculate dimensions: width = BMPSize.bmWidth; height = BMPSize.bmHeight; .... myWnd = CreateWindowEx( WS_EX_TOOLWINDOW, "my_win_class", WS_DLGFRAME, NULL, xpos, ypos, width, height, NULL, NULL, hInst NULL); The problem here is, suppose the bitmap is 640x480 pixels in size - the window created by this code will be exactly that size too, which doesn't work if there is a title bar and border, as these will be included in these dimensions. So the bottom of the bitmap will be cut off by the exact number of pixels that the titlebar takes up, or the right and bottom of the bitmap will be cut off by the number of pixels that the dialog frame border takes up. I hope that makes sense. Could someone please suggest a better way of calculating my window size so that it sizes itself to exactly fit whole of the bitmap, plus the title bar and border? Many thanks for any help, KB

    C / C++ / MFC help graphics question

  • Hiding the main app window created by ShellExecuteEx?
    K Kayembi

    Thanks for the reply, but unfortunately that only works for console/DOS apps (though I tried it anyway) - the app I'm launching is a Win32 EXE... Thanks for all the suggestions so far, KB

    C / C++ / MFC help question tutorial

  • Hiding the main app window created by ShellExecuteEx?
    K Kayembi

    Thank you for your reply but if you read my post you will see that I have already explained that this is not working, and why it's not working (because it's up to the application how it handles these flags, see MSDN). Any help much appreciated, Thanks, KB

    C / C++ / MFC help question tutorial

  • Hiding the main app window created by ShellExecuteEx?
    K Kayembi

    Hi, I have launched an executable from my program using ShellExecuteEx(). However, I want this program initially to run in the background in a hidden state. Setting the nShow property of the SHELLEXECUTEINFO structure to SW_HIDE in this instance doesn't work - presumably because the launched program won't allow it (in accordance with what it says on MSDN, ie. that this info is passed to the program but it's up to the program how to use it). Thus, I guess I need to explicitly call ShowWindow with SW_HIDE set to hide the window created. The problem is, how do I do this effectively, so that the main window of the program launched is hidden from the very start? At the moment I am using FindWindow(), like this: ShellExecuteEx(&app); HWND app_hWnd; while(app_hWnd == 0) //loop until app window is found { //if there is an error and the app closes, leave loop: if(WaitForSingleObject(app.hProcess,0)==WAIT_TIMEOUT) { ShowWindow((app_hWnd = FindWindow("app_mainwin",NULL)),SW_HIDE); //Ensure loading window is updated if anything happens in the meantime: if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } } else {break;} //if app has quit (eg. error), exit loop so we can end the program normally } This isn't a great solution, though, as the launched program window is shown for a couple of seconds before FindWindow() and ShowWindow() catch it and hide it. Does anybody know of a better way of doing this, so that the launched application window is not shown at all until I call ShowWindow again with SW_SHOW? ...Talking of which, I have a secondary problem relating to this. When I do call ShowWindow(app_hWnd,SW_SHOW) to restore the window, even after the window is shown again, it does not appear in the taskbar until I alt-tab out of it and back in again. How do I ensure that a program's window is restored to the taskbar on re-showing it? (I have tried SW_RESTORE, SW_SHOWNORMAL etc...) Any suggestions or help much appreciated, as always. Many thanks, KB

    C / C++ / MFC help question tutorial

  • How to save the structure of a tree view?
    K Kayembi

    Hi, I am nearing the completion of my app (and a big thank you to everyone here who has helped me so far - I've received a lot of help and do really appreciate it). I am currently working on saving project files, but there is one aspect of my app I have no idea how to go about saving, and would be very grateful for some advice. Part of my app works a little like Windows Explorer. On the left there is a folder tree and on the right a file list. The user can create a file tree containing a number of files, and upon hitting a "Build" button, the folder tree he or she has defined is created on disk, and the specified files copied into these folders (you may wonder what the advantage of this method is over just letting my user do all this in Windows Explorer, but trust me that this makes sense in the context of the rest of my app - for instance, the paths of the folders are stored as command-line parameters etc). So far, so good. However, when my user goes to save a project, the project must save the directory tree that he has created, and it is this that I do not know how to achieve. The directory tree is just a tree view - ie. a sequence of HTREEITEMs. On saving a project, the app needs to look at the tree view and save the structure, which can of course consist of an unlimited number of HTREEITEMS organised in any order with various properties. Upon loading a project, the app needs to be able to reconstruct this tree view just as it has been saved. I thought of using a string array to hold the paths of the folders and try to reconstruct them from the paths, and using a number array to hold the properties, but this seems a very long-winded way of doing it. Can anybody suggest a good method of dealing with this? I'm using the straight Windows API with _no_ MFC, but that shouldn't make too much difference as I'm not asking for code so much as for ideas about how one goes about storing information about something as complex and arbitrary as a customisable tree view. Many thanks for any help, KB

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

  • Better way of changing window title and icon at run-time?
    K Kayembi

    Hi, I have written an app that controls another application - it basically packs its files, allows customisation of its window title and icon, adds an alternative splash screen and various other features specific to the app. The application my app controls is third-party, so I have no access to its code. Everything is working fine, but I was wondering if there is a better way of changing the icon and window name at run-time than the methods I am currently using. (Incidentally, I am using the straight Windows API with _no_ MFC.) To change the window title, I have written this loop: //this loop finds the third party app window: while(thirdParty_hWnd == 0) //loop until window is found { //app was started using ShellExecuteEx - check it is still running: if(WaitForSingleObject(thirdPartyApp.hProcess,0)==WAIT_TIMEOUT) { thirdParty_hWnd = FindWindow("thirdpartyappclass_mainwin",NULL); SetWindowText(thirdParty_hWnd, "New Win Title"); //rename window if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } } else {break;} //3rd party app has closed } The problem here is that the window title of the third party app does not appear in the window immediately, so my code sets the title before the app does. This means that the title is changed back a second or less after this code has been executed, meaning that I have to check the window title again in my next loop and change it back if necessary, like this: char title_str[MAX_PATH]; //this loop handles the main stuff now that the window has been found: while(thirdParty_hWnd!=0) { if(WaitForSingleObject(thirdPartyApp.hProcess,0)==WAIT_TIMEOUT) { //set window text: GetWindowText(thirdParty_hWnd,title_str,MAX_PATH); if(strcmp(title_str,"New Win Title")!=0) { SetWindowText(thirdParty_hWnd,"New Win Title); } //message loop here } } Although this works, the main problem is that this means the window title is set to what I want ("New Win Title" in the example) at first, then it reverts to the default app title briefly before getting changed back to, for instance, "New Win Title". Does anybody know of a better way of doing this, so that the original app title would never show at all? (Also, please bear in mind that I a relative novice, so feel free to tell me where my code is shoddy and suggest improvements.) To change the icon, I use the following code: SendMessage(thirdParty_hWnd, WM_SETICON,(WPAR

    C / C++ / MFC c++ css json help tutorial

  • Subclassing a tree control?
    K Kayembi

    Hi, I have a tree view control in a dialog-based app (non-MFC) and I want to use VK_RETURN and VK_ESCAPE to send the TVM_ENDEDITLABELNOW message to end label editing. This is fairly difficult, because the dialog traps all key messages (I think). There is an article on MSDN that covers the basics of how to solve this here: http://support.microsoft.com/default.aspx?scid=kb;en-us;130691 Unfortunately I'm relatively new to coding C++, and I don't know how to go about implementing the advice given in that article. From the article: "To work around this problem, subclass the edit control in response to the TVN_BEGINLABELEDIT notification that is sent by the tree view control when the tree view is about to start label editing for an item. To obtain the edit control's window handle, send the tree view control a TVM_GETEDITCONTROL message. The subclass procedure should handle the WM_GETDLGCODE message by returning DLGC_WANTALLKEYS. This allows the tree view's subclass procedure to handle ESC and ENTER keystrokes." Could someone explain to me how to subclass the tree view control in this way to get this working, or point me to some examples (non-MFC)? Many thanks to anyone who can help, KB

    C / C++ / MFC c++ help com data-structures tutorial
  • Login

  • Don't have an account? Register

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