|
I hope this is an easy question. I have ten static text boxes with ids IDC_NAME0, IDC_NAME1, etc. Corresponding mapped variables are m_name0, m_name1, etc.
I want to create a loop so I can easily assign the same text to each box using a m_namex.SetWindowText command.
How can I create an expression to do this?
for(i=0;i<=9;++i) m_name??.SetWindowText("hello");
I'm using VS 6.0, C++, dialog based application.
|
|
|
|
|
Use an array instead of separate variables, so instead of having m_name0, m_name1, ... m_nameX, declare m_names[X] and then do
for (int i = 0; i < X; i++) m_name[i].SetWindowText("hello world");
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thanks, that was easy enough. I was using class wizard to create the variables and it wouldn't let me specify an array index, so I thought it wouldn't work that way. However I was able to change it in the header file and message map and it worked so go figure! Thanks again
|
|
|
|
|
callmeishmael25 wrote: How can I create an expression to do this?
If the IDs are sequential:
for (i = IDC_NAME0; i <= IDC_NAME9; i++)
SetWindowText(i, "hello");
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Not sure if this is the right forum since it also has to do with ATL but..
I'm programming a shell extension dll (context menu) based off the article "The Complete Idiot's Guide to Writing Shell Extensions" by Michael Dunn. So I made an ATL project with MFC and COM support. At first I started by using SetMenuItemBitmaps() to set the menu item icons, but then I found out that this method doesn't support transparency.
Because achieving transparency for menu icons is apparently far from straightforward, I had the marvelous idea of looking at the Tortoise CVS shell code. I incorporated some of the ideas like using LoadImage() and GDI plus on Vista to blit the icons to a bitmap and make them look good that way, but I also noticed that they didn't use ATL and did reference counting themselves (and as such are also easily able to access the DLL's instance handle).
My problem now is that each LoadImage() call fails with error code 1813 which according to MSDN means "The specified resource type cannot be found in the image file.".
Now my best bet is that I'm somehow using the wrong module handle (the one of the EXE perhaps instead of the DLL), but I've tried everything I can think of to get the correct handle including:
1. Use the m_hInstance member of the global CWinApp instance.
2. Just pass in NULL for LoadImage().
3. Use GetModuleHandle() with the dll name passed in. This returns a handle but it still fails with 1813.
4. Use MFC's AfxFindResourceHandle() to get a handle to the dll instance. This fails with an assertion error in some MFC file saying the current resource handle is not set (so i tried setting it with AfxSetResourceHandle() to the theApp.m_hInstance handle, but that just crashed).
I'm starting to wonder if the people from tortoise intentionally decided not to use ATL so they could get the instance handle from DllMain(). Either way, it seems to me that I've bumped into some internal MFC/ATL funkyness and I can't figure it out.
So if anyone knows more about this or has any suggestions, do tell
Oh yea, note:
For the resource I'm testing with I'm simply using a string id such as "IDI_TORTU" which I then pass to LoadImage().
greets
Kuniva
--------------------------------------------
|
|
|
|
|
Try using the resource ID (numeric) with MAKEINTRESOURCE instead of the "IDI_TORTU" thing... aside of that, you sure you are specifying the right flags to LoadImage, maybe you are trying to load a BITMAP instead of an ICON and it cannot find a BITMAP among the resources with that ID (since it is an ICON) thus the error?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Code-o-mat,
The LoadImage call looks like this:
HICON hIcon = (HICON) LoadImageA(handle, sIcon.c_str(), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
So it is loaded as type IMAGE_ICON, which it is in the resource file (I just copied the tortoise icon).
Hmm I just tried it with a numeric identifier with MAKEINTRESOURCE and that does work however.. I want to use string identifiers like tortoise does because I'll be loading which icon to use from a configuration file (and I don't want to use numbers to indicate icons in that).
I must be doing something wrong with the resources.. :/
Kuniva
--------------------------------------------
|
|
|
|
|
Alternatively you could "convert" the strings you use in the configuration file into numeric IDs in your code (like if (strid == "IDI_TORTU") numid = IDI_TORTU; else ... ). I always used MAKEINTRESOURCE with LoadImage so i'm not sure about string-identification...could it be that the method doesn't actually expects you to specify "IDI_TORTU" but rather the file name the resource was imported from, for example "my_tortu_icon.ico"?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Eureka! : )
No it was nothing like that. Seems all this time I've been looking in the wrong place.
I didn't know that for your resources to have string identifiers, you need to remove the define in whatever your numeric resource header file is maintained by visual studio. I just deleted IDI_TORTU in resource.h and now it works like a charm (doh ).
Thanks for your help, if I hadn't simply tested with MAKEINTRESOURCE I'd still be debugging for instance handles
Kuniva
--------------------------------------------
|
|
|
|
|
We always learn something new...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi all. I need to invoke a dll/exe upon selection of controls in flash like checkboxes,radio buttons etc..
By getting the status of the controls I need to perform the actions in my aplication which is developed in VC++ and accordingly I should give responses to flash.
All these process sholud be done inside the flash player only. Suggest me all the possible ways.
Referece materials/Solutions with code are much appreciatable..
thanks,
Praveen
|
|
|
|
|
Does this[^] help?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Lord, if he's confused now, he'll be completely lost reading that guys code. Good luck!
|
|
|
|
|
If I remember correct, FSCommand will help to communicate with Application...
- ns ami -
|
|
|
|
|
you can use FSCommand and socket .
|
|
|
|
|
the code in the first answer doesn't involve FSCommand and i think he is right to deal with communication between flash and C++
|
|
|
|
|
Hi,
I'm working on an application where it loads a huge file (like 4-6GB) and parses the file, searching for regular expressions, converting from Hex to Human readable form, filters etc.
Since the file is of very large size, I'm facing lot of performance issues where it takes hours to process and show the file information in a window.
To overcome this, what I did is, break the entire file into logical segments of 1 MB each and process 3 segments at a time. When the user is scrolling, the next segments will be processed. With this, a certain amount of improvements were done. But it is limited to files which are less than 300MB or so. For files which are over GBs, it is just crawling and pathetic.
Wondering if there is any better way to handle these large files in a better way so that the user need not wait for hours?
Will a buffered read and caching the decoded information in a temporary files using a thread would help? How can we make sure that the GUI doesn't hang during these intensive parsing process?
Really appreciate your suggestions.
Thanks
Vikas
|
|
|
|
|
by the way, the application is written in MFC
|
|
|
|
|
You could do memory mapping for the file segments.
You should get hold of a good profiler and check where the actual bottle neck is.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Vikas K. wrote: How can we make sure that the GUI doesn't hang during these intensive parsing process?
What about using a worker thread?
- ns ami -
|
|
|
|
|
I've had pretty good performance with memory mapped files (I've only used files up to about 1GB). What you need to do is create a file mapping with CreateFileMapping and then use MapViewOfFile to map segments of the file.
I worked with 16MB windows on the file, which actually meant I mapped 32MB at a time, 16MB before and after the nominal file offset, so that negative random accesses from the file offset didn't fault over into the previous window - something like the diagram below:
+----------------+----------------+
| | |
| | |
| | |
+----------------+----------------+
^ ^ ^
| | |
-16MB Requested +16MB
offset into file
I packaged this up into a MemoryMappedFile class which had an associated randomly-access iterator class (like a vector has an iterator). The memory mapped file could only be accessed using the iterator, which was exposed using 'begin' and 'end' methods of the memory mapped file class.
On a reasonable workstation (2.4GHz Core 2 Duo), I could traverse the file at around 100MB/second when counting data packets whose size was roughly 200 bytes.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you for your suggestions. Willwork on them and update .
|
|
|
|
|
Hi to All,
I am trying to make a win32 dll.
I just wanted to make sure if we can use the win32 dll in all types of application project or all type of languages. I am sure about Vb. What about other languages? Will it work?
Thanks in advance
HimangshuS
I am a learner Always
|
|
|
|
|
himangshuS wrote: I am trying to make a win32 dll.
Well, have fun with it!
himangshuS wrote: I just wanted to make sure if we can use the win32 dll in all types of application project or all type of languages. I am sure about Vb. What about other languages? Will it work?
The correct answer is no. The practical, common sense answer, is yes (provided the target OS is Windows and you're ready to put some effort in the task...)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi
thanks for your reply
Could you please put some more light into it...
thanks
I am a learner Always
|
|
|
|