You have a memory leak when you call "new[]" without a corresponding "delete[]" (note that this is "delete[]" with square brackets, not just "delete"). I would suggest taking a more modern C++ approach to reading the file that eliminates the issue of manual memory management altogether: Include these headers: #include #include Then do this: std::wifstream file(path); std::wstring contents((std::istreambuf_iterator(file)), std::istreambuf_iterator()); SetWindowText(hEdit, contents.c_str()); This solves your memory leak and leaves the task of memory management to the C++ standard library. Overall great tutorial videos though!
@grekzorna87507 ай бұрын
@Inmasj0ns This is not object oriented though...
@DavePaddy4 жыл бұрын
This was VERY useful tutorial series. I wish you did more of these, you're explaining very well.
@ajupeter11254 жыл бұрын
Tributes! to a great teacher you are!.... Thank you so much for explaining things so beautifully.. Pray you do well in everything you do.
@kimlynhep14626 жыл бұрын
Where is part 10?
@billtsou80716 жыл бұрын
I really like your tutorial. Your English is easy to understand. What you've taught us are extremely helpful for beginners. Hope that you can publish part 10 of GUI tutorial. Thanks!!
@hk-aerialvtol43716 жыл бұрын
Thanks for the 9 video into to Win32. This was extremely well thought out and presented.
@santiagomendezmejia71556 жыл бұрын
Thanks !!!! For me this is the best tutorial of Win32 API. Greetings from Colombia
@aibou23995 жыл бұрын
Thanks for this video series, i was afraid of diving in this old school c style api, but it was a confortable trip with your tutorials.
@Martin-wz5rm5 жыл бұрын
Can you please do a tutorial on checkboxes?
@brendananderson91023 жыл бұрын
Yeah, I wanted to program a GUI with bullet points. I guess I'll have to find a tutorial elsewhere.
@Lugmillord6 жыл бұрын
Thank you for this tutorial series. This really helped me getting started with the Windows API!
@timobeyer98706 жыл бұрын
We want Part 10♥
@benmac68625 жыл бұрын
Why do you sometimes use the underscore _ before a variable ?
@PerchEagle Жыл бұрын
Hi .. I have a question, do you have a blog page or email so I send you my problem ? I'm trying to print multiple page on the same hWnd object.
@noteng0 Жыл бұрын
Excellent list bro, was so helpfull to me and my projects :)
@carloseduardomayerdeolivei29132 жыл бұрын
Congratulations! Thank you for the great information that you have provide us!
@alvinhi54676 жыл бұрын
Nice, did you have example for create trackbar in windows GUI C++
@peterSobieraj Жыл бұрын
So there will be challenge in next video, and it was last video in series. :D
@emanoel.g.s Жыл бұрын
I have a problem, can you help me? I need to read a file, execute a series of procedures (which take time), and during the procedure I want to show text messages (debug) on the "hEdit" screen. However, it is only after the process is finished that writing is done on the "hEdit" screen. Is there any way for the two processes to coexist?
@starwinner49825 ай бұрын
Take a look at multithreading. Use one thread for the main loop of the window, where you handle all the events, and another thread for reading the file. In order to get updates on how much of the file has been read, then read the file byte by byte - after each byte notify the other thread about the progress. If you ask how to share this progress? Then just store the pointer of the first object, where the function that is multithreaded, is running. Then just update some array with that pointer. Hope this helped! :)
@ahmedessamahmed8606 жыл бұрын
How to add sound in the program? please say, thank you
@brazo983 жыл бұрын
Thx a lot about your perfect tutorials. So, one question, how can read from a windows a panel objects? For example a label or textedit field? Is this possible with the findwindowex function? Or via getwindowstext? It make me really creepy that problem! Thx a lot for a answere. Please keep healthy! 🖖🏻🖖🏻🖖🏻
@MasterMindmars2 жыл бұрын
Thank you so much. Could you make a video for draw circles, lines, rectangles. ..? Greetings.
@mikeroland99632 жыл бұрын
Very useful tutorial, thank you, brother !
@EliasNPC6 жыл бұрын
Could you do these tutorials while using ResEdit for styling?
@W3Bches33 жыл бұрын
Next part(10):
@mariodvillarreal4 жыл бұрын
I want to retrieve data from another application. With window spy, i can get all structure of forms, including theirs Id. But, can't retrieve data. Anyone can help me?
@cato_ix6 жыл бұрын
Hey! How do you remove the terminal? This has helped me figure out a couple things, but I don't want to have the extra program open in the background.
@aibou23995 жыл бұрын
If you are compiling from command line, use the "-mwindows" flag.
@MohamedGaber-sv6nh3 жыл бұрын
شكرا لك يا صديقي😀🙂 لقد ساعدتني في الكثير🙂
@andreimiga81016 жыл бұрын
I have a question. How do you change the font of the controls? The default font looks bad.
@animalvids63125 жыл бұрын
everything in windows is done by sending messages. enjoy docs.microsoft.com/en-us/windows/desktop/controls/edit-controls-text-operations
@srinivasreddy43065 жыл бұрын
10 bro plz
@code-to-learn3 жыл бұрын
More part please! About media player
@toadvices15028 ай бұрын
Hello, can i have the source code of this project? regards
@newgatefullbustar83665 жыл бұрын
thanks so much for these wonderful series.
@nastyavicodin62296 жыл бұрын
I don't understand why but when I open file in usual text editor after every line it's additional empty line. Help me pls with this problem. Code was the same as in video
@ThePentamollisProject6 жыл бұрын
try this char* data[length + 1]; GetWindowText (hInputField, data, length); data[length] = '\0'; fwrite(data, length, 1, file); i didn't pay much attention to the file I/O code so there might be problems with that.
@nastyavicodin62296 жыл бұрын
In notepad all files are ok When I open it in Sublime text my files became smth like this: 2369 6e63 6c75 6465 0d0d 0a0d 0d0a 6865 6c6c 6f5f 776f 726c 640d 0d0a 7772 6974 6528 2900 But this happend only if I edit empty files.
@nastyavicodin62296 жыл бұрын
This is my first version of write_file func: void write_file(char *path) { FILE *file; file = fopen(path, "w"); int _size = GetWindowTextLength(hFile_cont); char *data = new char[_size + 1]; GetWindowText(hFile_cont, data, _size + 1); fwrite(data, _size + 1, 1, file); fclose(file); }
@nastyavicodin62296 жыл бұрын
This is second version: void write_file(char *path) { FILE *file; file = fopen(path, "w"); int _size = GetWindowTextLength(hFile_cont); char *data = new char[_size + 1]; GetWindowText(hFile_cont, data, _size); data[_size] = '\0'; fwrite(data, _size, 1, file); fclose(file); }
@nastyavicodin62296 жыл бұрын
When I changed my write_file func nothing changed in output, still empty lines and NULL in the EOF
@MisterTyken5 жыл бұрын
Awesome work, I've found something that might prove to be difficult for the viewers that I've run into. If you don't load a file then it crashes because it doesn't have a file to load and goes onto the next function as if it did. A little help on this fix would be helpful
@FrostGamingHype3 жыл бұрын
i Still Want A Short Way For This Is Too Many Void Function Going IN My Mind Bro There Should Be An Smaller And Shorter Way To Do IT You Know
@mikejzx6 жыл бұрын
Great tutorial, but I believe you forgot to insert the terminating character '\0' into the data before writing, because I noticed when I opened the saved file in Programmer's Notepad there was a character at the end which said "NUL". But I think that was because of the data size being 1 int too large. Here's what I did to prevent this: char* data[length + 1]; GetWindowText (hInputField, data, length); data[length] = '\0'; fwrite(data, length, 1, file); Let me know of any errors I made. I think the ' + 1' isn't actually required for this.
@ThePentamollisProject6 жыл бұрын
Yes you're right, and sorry for this silly mistake. I was just focusing on the stuff that was related to the API and i didn't pay much attention to the input/output code.
@mikejzx6 жыл бұрын
No worries mate, we all make mistakes ;)
@Lugmillord6 жыл бұрын
I tried your code and when opening the file, the last character was replaced by a space. This worked fine for me: char* data = new char[sizeOfContent + 1]; data[sizeOfContent] = '\0'; GetWindowText(hFileOutput, data, sizeOfContent + 1); fwrite(data, sizeOfContent, 1, file);
@mikejzx6 жыл бұрын
+Lugmillord Interesting... In your code, I don't think the '\0' is even being written to the file, because your specified length in fwrite doesn't have the + 1. And also you called GetWindowText after assigning the last char of data to '\0', so it would probably be replaced anyway.
@Lugmillord6 жыл бұрын
I thought so, too. But when I switched the lines, the last character was replaced and I found an extra space in the text file. Maybe allocate length + 2?
@rajjoshi63006 жыл бұрын
Hey, is there a way that we can see your complete source code from all the files? I want to see it in one place so I can understand it better. I need to do this for my marking period project. Your videos are great and keep working hard!
@ThePentamollisProject6 жыл бұрын
I dont have separate sources of all the tutorials as i edit the same project everytime. Although I do have the source of Part 9. And i think i might be able to dig up the source of part 6 or 7. I can email it all to you you if you provide your id, or alternatively, you can text me at the facebook page of this channel ( facebook.com/pentamollis ), and i'll send the code there. :-)
@rajjoshi63006 жыл бұрын
I will message you on your facebook page
@GtTrader675 жыл бұрын
post the complete code file.
@doelekkerrechts37826 жыл бұрын
I notice how you use "new" to allocate an array without deleting it afterwards. Are you more familiar with Java? Nevertheless, it's a helpful tutorial. Thanks.
@timothywrona63814 жыл бұрын
He actually uses "new[]" which is not quite the same as "new". In order to avoid a memory leak the "delete[]" operator with square brackets must be called. These kinds of subtle details make it very easy for mistakes to happen so it would really be better to just use a "std::ifstream" to read the file and leave the task of memory management to the standard library.
@hungtrinh71693 жыл бұрын
thank you , i am Vietnamese ,HoangSa TruongSa by VIETNAM