|
You can use TRACE to see the exact value(s) of itemAction member.
|
|
|
|
|
I am not sure that you should be using CB_GETLBTEXT to get your items for drawing. The usual process for an owner drawn control, is that you would have your list of items somewhere in your application. However, it is some while since I have done this so would need to review my code.
|
|
|
|
|
My process is that I do Addstring with values I have
Then when clicking right icon dropdown on the combo box The Drawitem exit is invoked, allowing me to format that string with font, the rcitem RECT member has Dimensions from the MeasureItem exit
the problem is at the end of stepping thru DrawItem the listbox remains intact non displayable.
Victor Suggested I use TRACE have to look into that
Thanks
|
|
|
|
|
Hi
I need to detect BackSpace as well as Delete Key in a Edit Box placed on Dialog Box in a Dialog based Application. The Problem is that Edit Box has no more Events like WM_CHAR, WM_KEYDown and WM_Key Up.
Thanks
|
|
|
|
|
|
I want to start learning C++ and create kind of windows applications like what is made in C# and WPF. I have three options: VS 2022, Code::Blocks, and QT creator 6. Which one is good for developing elegant windows applications?
modified 29-May-22 13:56pm.
|
|
|
|
|
I will address the question in the title. There`s only one IDE left (for 10 years now) so it`s not like you have too many options.
|
|
|
|
|
Is Code:Blocks good for this purpose? Can I create elegant GUIs using it?
|
|
|
|
|
I had to look up Code::Blocks and noticed that it incorporates wxWidgets. I don't develop GUI apps, but when I looked into the area a while ago, I bookmarked wxWidgets so I could return to it if I ever needed to. C++ doesn't have a GUI library, so you have to find one. And if you want to support different platforms, not just Windows, you need something like wxWidgets, not WPF.
As far as an IDE goes, VS2022 (Community Edition) is free and an excellent IDE. You can probably develop using wxWidgets within VS2022, but you'd likely have to spend some time configuring it, whereas Code::Blocks looks like it should work immediately. But I know next to nothing about this, so you need to get input from someone who does.
|
|
|
|
|
|
Perhaps poorly worded. Not part of the C++ standard, in the same way that it doesn't have sockets.
How many platforms does Windows Controls support?
|
|
|
|
|
I take your points. But C# does not have those features either, as part of the standard. The libraries are implemented in the same way that the Win32 or MFC libraries are.
Yes, Windows controls only work in the Windows OS.
|
|
|
|
|
Is it possible to have relative element position in C++ GUI (using visual studio) like what we have in WPF?
|
|
|
|
|
No, you have to do the layout calculations yourself. And TBH if GUI applications are your main focus then I would suggest you stick to .NET with C# or VB.NET.
|
|
|
|
|
I'd only heard of VS2022, so I had to do a search on the others. I assumed that your response meant that the others were no longer in business, but they still seem to be undergoing development.
|
|
|
|
|
When your project is causing you enough headake on its own, last thing you want is errors because of a buggy IDE/compiler.
There is no serious match for VS from what I know.
|
|
|
|
|
Qt Creator is worthwhile ONLY if you embrace Qt. Qt is great but is like its own OS. I still vastly prefer Visual Studio and so did my Qt development with it. Had I ported my last app to Linux, only then would I use Qt Creator.
Don't bother with Code::Blocks. It's adequate for Linux but a waste of time for Windows. Moreover, for Linux CLion is vastly superior.
|
|
|
|
|
Visual Studio is always the best choice for creating Win32 GUI applications as it integrates all the tools you will need. It also includes a simple template to create your first GUI program (although it is a bit clunky). And the standard Windows Controls - Win32 apps | Microsoft Docs[^] cover most control types you are likely to need.
|
|
|
|
|
With no prior baggage, I would think that WinUI 3 and VS2022 (with C++) would be the route.
About WinUI
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I will start with my code:
template < typename T1, typename T2 >
void printvector(T1& fout, const std::vector < T2 >& V)
{
if (V.empty()) fout << "EMPTY\n";
else {
for (size_t x = 0; x != V.size() - 1; ++x)
{
fout << V[x] << ", ";
}
fout << V[V.size() - 1] << '\n';
}
}
fstream StatFile;
StatFile.open(STATICFILE, std::fstream::out);
if (StatFile.is_open())
{
for (i = 0; i != NewLandmarks.size(); ++i)
{
cout << NewLandmarks[i].name << " "; printvector(cout, Subtractions);
StatFile << NewLandmarks[i].fiducial << ", " << NewLandmarks[i].name << ", "; NewLandmarks[i].location.print(StatFile);
if (Subtractions.empty()) StatFile << "\n";
else {
StatFile << ','; printvector(StatFile, Subtractions);
}
}
StatFile.close();
}
The template is supposed to print out the contents of a vector, either to the console when given cout, or to a text file when given an fstream variable.
NewLandmarks is a vector of a struct and that seems to be working just fine here.
Subtractions is a vector of size_t, and this is where the problem lies.
When the code runs, the NewLandmarks name is printed to the console, as well as the contents of the Subtractions vector, which in this case is always 45, 46, 47, 48
When the code gets to the next line, where it prints to the file, NewLandmarks.fiducial, NewLandmarks.name and NewLandmarks.location.print(StatFile) all work as expected.
However, the Subtractions vector only prints its last element, 48, to the file. This implies that the Subtractions vector somehow got changed by the printvector template. But, I don't see how, or why.
Even more confusing, this code loops several times. The first time Subtractions prints to the file as 48. The second time it prints as 47, 48. The third time as 46, 47, 48. I don't loop through a fourth time, but I think I can see what would happen. But I still don't know why. Even worse, during each of these loops when Subtractions is printed to the console I always get the full vector: 45, 46, 47, 48.
So,
Why is the template function behaving differently from its console and file printing activations?
Why does the template function write only the last element of the vector to the file and its first iteration?
Why does the template function change behavior and write an additional vector element each time it runs?
In case it is relevant, NewLandmarks.location is a Vector (a mathematical Vector class that I created) and its print function looks like this:
(L is the length of the Vector)
void Vector::print(std::fstream & fout) const {
for (size_t i = 0; i != L; ++i) {
fout << std::setprecision(15) << std::setw(22) << v[i];
if (i != L - 1) fout << ',';
}
}
Even if this is somehow causing my problem, I still do not see how or why. But, it seems to be working fine.
Thank you for your help
|
|
|
|
|
|
Yes, or that is what I am in the process of doing. I found this unexpected behavior and I do not know why it happens or how to fix it.
|
|
|
|
|
Probably there is part of your code (not posted here) messing up with the Subtraction vector.
This code
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
template < typename T1, typename T2 >
void printvector(T1& fout, const std::vector < T2 >& V)
{
if (V.empty()) fout << "EMPTY\n";
else {
for (size_t x = 0; x != V.size() - 1; ++x)
{
fout << V[x] << ", ";
}
fout << V[V.size() - 1] << '\n';
}
}
int main()
{
vector <size_t> sub {46,47,48};
printvector(cout, sub);
fstream foofile("foo.txt", ios::out);
if (foofile)
{
printvector(foofile, sub);
}
} produces the same output
46, 47, 48 both to the console and to the foo.txt file.
[update]
Note, you might also write
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
template <typename T>
ostream & operator<< (ostream & os, const vector <T> & v)
{
if ( v.empty() ) os << "EMPTY\n";
else
{
for (size_t n = 0; n != v.size() - 1; ++n)
{
os << v[n] << ", ";
}
os << v.back() << '\n';
}
return os;
}
int main()
{
vector <size_t> sub {46,47,48};
cout << sub;
fstream foofile("foo.txt", ios::out);
if (foofile)
{
foofile << sub;
}
} [/update]
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
modified 24-May-22 6:02am.
|
|
|
|
|
That is what I thought at first. But why does the vector print correctly when it is to the console and incorrectly when it is to a file, and the two commands are right next to each other. Where was the opportunity to screw up the Subtractions vector?
|
|
|
|
|
You only, having the full code, might know.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|