How to load resorces of a form that is not loaded
Author |
Message |
Eduard #1 / 25
|
 How to load resorces of a form that is not loaded
I want to load the resources of a form without loading the form. For example: The project has two forms: Form1 and Form2. Form1 is the startup form. Form2 has a picturebox with an image loaded in its Picture property. At design time the data of that image is stored in the Form2.frx file. At runtime it is stored in the exe file. The project run, Form1 is loaded (but form2 isn't). I want to be able to load in Form1 (may be in another picturebox that is in Form1) the image of Form2.Picture1.Picture without loading Form2. At least, I want to do that when the program is compiled. At design time I could manage my situation in another way. If can can do that at run time and also at design time, the better. Why I need that? I'll explain it later, or you can read this discussion here: http://www.*-*-*.com/ Thanks.
|
Sat, 26 Mar 2011 06:39:04 GMT |
|
 |
Mike #2 / 25
|
 How to load resorces of a form that is not loaded
Quote:
>I want to load the resources of a form without loading the form. > For example: The project has two forms: Form1 and Form2. Form1 is the > startup form. > Form2 has a picturebox with an image loaded in its Picture property. > At design time the data of that image is stored in the Form2.frx file. At > runtime it is stored in the exe file. > The project run, Form1 is loaded (but form2 isn't). I want to be able to > load in Form1 (may be in another picturebox that is in Form1) the image of > Form2.Picture1.Picture without loading Form2. > At least, I want to do that when the program is compiled. At design time I > could manage my situation in another way. If can can do that at run time > and also at design time, the better.
Don't put the image in a PictureBox at all at design time. Add it to a resource file and at runtime load it from that. Look up LoadResPicture in VB's Help. If the image's format is not bitmap, icon, or cursor, you'll either have to convert it to one of those formats before adding it to the resource file (because LoadResPicture only works with one of those 3 formats) or load it from the resource file in another way (still possible, but more involved, look up LoadResData in VB's Help). Quote: > Why I need that? I'll explain it later, or you can read this discussion > here: > http://tinyurl.com/3kccaw
Please don't use tinyurl.com. People have no easy way of knowing (and perhaps no way at all) where it's actually taking them, so most people won't click the link and most also aren't going to spend the time to figure out where it takes them (assuming it's even possible to find out). -- Mike
|
Sat, 26 Mar 2011 07:07:53 GMT |
|
 |
Eduard #3 / 25
|
 How to load resorces of a form that is not loaded
Hello: Quote: >> Why I need that? I'll explain it later, or you can read this discussion >> here: >> http://tinyurl.com/3kccaw > Please don't use tinyurl.com. People have no easy way of knowing (and > perhaps no way at all) where it's actually taking them, so most people > won't click the link and most also aren't going to spend the time to > figure out where it takes them (assuming it's even possible to find out).
The url is: http://groups.google.com/group/microsoft.public.vb.controls.creation/... I used tinyurl because in some news clients the url may be cut, but you're right, it can redirect to any malicious page.
Quote:
>>I want to load the resources of a form without loading the form. >> For example: The project has two forms: Form1 and Form2. Form1 is the >> startup form. >> Form2 has a picturebox with an image loaded in its Picture property. >> At design time the data of that image is stored in the Form2.frx file. At >> runtime it is stored in the exe file. >> The project run, Form1 is loaded (but form2 isn't). I want to be able to >> load in Form1 (may be in another picturebox that is in Form1) the image >> of Form2.Picture1.Picture without loading Form2. >> At least, I want to do that when the program is compiled. At design time >> I could manage my situation in another way. If can can do that at run >> time and also at design time, the better. > Don't put the image in a PictureBox at all at design time. Add it to a > resource file and at runtime load it from that. Look up LoadResPicture in > VB's Help. If the image's format is not bitmap, icon, or cursor, you'll > either have to convert it to one of those formats before adding it to the > resource file (because LoadResPicture only works with one of those 3 > formats) or load it from the resource file in another way (still possible, > but more involved, look up LoadResData in VB's Help).
I repeat my original question, because in my case using a resource file is not an option. Thanks.
|
Sat, 26 Mar 2011 07:39:12 GMT |
|
 |
expv #4 / 25
|
 How to load resorces of a form that is not loaded
OT: You can go to tinyurl home page and select "Preview feature" to the left and enable it, so you are not redirected automatically and see the URL. It requires cookies though. http://tinyurl.com/preview.php
|
Sat, 26 Mar 2011 07:54:03 GMT |
|
 |
Mike #5 / 25
|
 How to load resorces of a form that is not loaded
Quote:
> I repeat my original question, because in my case using a resource file is > not an option.
Why not? A resource file gets compiled into your exe, dll, ocx. From that standpoint, it's really no different than adding the image to a PictureBox at design time. I could be wrong, but something tells me you simply aren't familiar with resource files. And another posting tip...if you're going to quote that much and continue your reply, at the very top of your reply say something like "comments inline" or something to that effect to let people know. Once they see what's quoted and your reply to that, they may just assume that's all there is. I'd bet that many people wouldn't have scrolled enough to see that you wrote more. BETTER is to limit how much you quote to just what's relevant to the flow of the discussion and therefore keep the entire message as short as possible. -- Mike
|
Sat, 26 Mar 2011 08:04:27 GMT |
|
 |
Mike #6 / 25
|
 How to load resorces of a form that is not loaded
Quote: > OT: You can go to tinyurl home page and select "Preview feature" to the > left and enable it, so you are not redirected automatically and see the > URL. It requires cookies though. > http://tinyurl.com/preview.php
Wouldn't help me because I have cookies disabled by default. Cookies are only enabled for trusted sites. Even if I DID have cookies enabled, I wouldn't waste that much time (don't care if it'd actually only take a few seconds) to go to that URL. I've got nothing against tinyurl.com. I think it's a great thing for certain purposes. But newsgroup posts are NOT one of them. -- Mike
|
Sat, 26 Mar 2011 08:10:25 GMT |
|
 |
Eduard #7 / 25
|
 How to load resorces of a form that is not loaded
Quote:
>> I repeat my original question, because in my case using a resource file >> is not an option. > Why not?
In my first post I said: "Why I need that? I'll explain it later, or you can read this discussion here: [URL]" Quote: > I could be wrong, but something tells me you simply aren't familiar with > resource files.
That "something" is laying to you.
|
Sat, 26 Mar 2011 08:21:13 GMT |
|
 |
Eduard #8 / 25
|
 How to load resorces of a form that is not loaded
Note for everyone: Please dont take it wrong, but please don't attempt to provide alternative solutions if you don't undestand the actual problem. And I'll simplify my question: How to read form the compiled exe file resources used in a form by its controls? (like a bitmap).
|
Sat, 26 Mar 2011 08:26:34 GMT |
|
 |
Mike #9 / 25
|
 How to load resorces of a form that is not loaded
Quote:
> Note for everyone: > Please dont take it wrong, but please don't attempt to provide alternative > solutions if you don't undestand the actual problem. > And I'll simplify my question: > How to read form the compiled exe file resources used in a form by its > controls? (like a bitmap).
You can't WITHOUT loading the form...and since you seem to be against that, you're rather limited. Using the API, you might be able to do this (the bitmap IS compiled into the EXE somewhere, but not necesarily as a resource that you can get at without loading the form and referencing the control), but it wouldn not be NEARLY as simple as using a resource file. -- Mike
|
Sat, 26 Mar 2011 08:37:31 GMT |
|
 |
Eduard #10 / 25
|
 How to load resorces of a form that is not loaded
Quote:
>> Note for everyone: >> Please dont take it wrong, but please don't attempt to provide >> alternative >> solutions if you don't undestand the actual problem. >> And I'll simplify my question: >> How to read form the compiled exe file resources used in a form by its >> controls? (like a bitmap). > You can't WITHOUT loading the form...and since you seem to be against > that, you're rather limited.
I think that the couple of times that I said that something was impossible in VB6, I was wrong. Quote: >Using the API, you might be able to do this (the bitmap IS compiled into >the EXE somewhere, but not necesarily as a resource that you can get at >without loading the form and referencing the control), but it wouldn not be >NEARLY as simple as using a resource file.
Of course, use the API, subclassing, of whatever you think is the way to do that (but I wouldn't like to add another dependency file, like a new typelib). I'm not looking for a simple way, I'm looking for a way. Thanks. Quote: > -- > Mike
|
Sat, 26 Mar 2011 08:49:11 GMT |
|
 |
Mike #11 / 25
|
 How to load resorces of a form that is not loaded
Quote:
>>> I repeat my original question, because in my case using a resource file >>> is not an option. >> Why not? > In my first post I said: "Why I need that? I'll explain it later, or you > can read this discussion > here: [URL]"
And you expect me or anyone else to read all that to determine the "why"? Maybe those that followed the original thread can understand your dilemma better than I, but since I didn't have enough interest in the original thread to follow it, I'm certainly not going to go back and study it now just to find out why you can't use a resource file. Quote: >> I could be wrong, but something tells me you simply aren't familiar with >> resource files. > That "something" is laying to you.
I don't understand 'laying to you" (trust me, I'm not getting laid tonight; why else do you think I'm reading the newsgroups? <g>). A resource file, from what I understand of your issue, seems the best course for you to take IMO. If you're against that for whatever reason, that's not mine, nor anybody else's, problem. It's yours. If you don't want to follow advice or assistance you're given here, that's your choice and that's fine. But sometimes, it really may be your best (and sometimes only) option, so you have to take it or leave it. -- Mike
|
Sat, 26 Mar 2011 08:52:29 GMT |
|
 |
Mike #12 / 25
|
 How to load resorces of a form that is not loaded
Quote:
>> You can't WITHOUT loading the form...and since you seem to be against >> that, you're rather limited. > I think that the couple of times that I said that something was impossible > in VB6, I was wrong.
Yes, you can do more with VB6 than most people realize because they've never even bothered to try. But it does have its limits. Quote: >>Using the API, you might be able to do this (the bitmap IS compiled into >>the EXE somewhere, but not necesarily as a resource that you can get at >>without loading the form and referencing the control), but it wouldn not >>be >>NEARLY as simple as using a resource file. > Of course, use the API, subclassing, of whatever you think is the way to > do > that (but I wouldn't like to add another dependency file, like a new > typelib). > I'm not looking for a simple way, I'm looking for a way.
I've given you the best advice I can think of given what I understand of the issue. If that's not good enough for you, I guess you just have to hope somebody else will reply that can offer that "other way". -- Mike
|
Sat, 26 Mar 2011 09:01:07 GMT |
|
 |
Eduard #13 / 25
|
 How to load resorces of a form that is not loaded
Quote:
>>>> I repeat my original question, because in my case using a resource file >>>> is not an option. >>> Why not? >> In my first post I said: "Why I need that? I'll explain it later, or you >> can read this discussion >> here: [URL]" > And you expect me or anyone else to read all that to determine the "why"? > Maybe those that followed the original thread can understand your dilemma > better than I, but since I didn't have enough interest in the original > thread to follow it, I'm certainly not going to go back and study it now > just to find out why you can't use a resource file.
I realize that you don't have much interest because you harry up to answer something but not to my original question. If you don't have interest, that's ok, but then don't say things that are not answers to the case. And I don't know if someone from the original thread really undestood the problem, but I also realize that to explain the problem to someone that is not very familiar with ActiveX controls, it is hard, so I decided to set my question on what I think may be a solution (may be there are other solutions, but to find one, one must first understand the problem). Quote: >>> I could be wrong, but something tells me you simply aren't familiar with >>> resource files. >> That "something" is laying to you. > I don't understand 'laying to you"
lying (trust me, I'm not getting laid tonight; Quote: > why else do you think I'm reading the newsgroups? <g>). A resource file, > from what I understand of your issue, seems the best course for you to > take IMO. If you're against that for whatever reason, that's not mine, nor > anybody else's, problem. It's yours. If you don't want to follow advice or > assistance you're given here, that's your choice and that's fine. But > sometimes, it really may be your best (and sometimes only) option, so you > have to take it or leave it.
I'm not against resource files, but I can't add a resource file to the host project from within my ActiveX control. Quote:
|
Sat, 26 Mar 2011 09:12:10 GMT |
|
 |
expv #14 / 25
|
 How to load resorces of a form that is not loaded
Quote:
> Note for everyone: > Please dont take it wrong, but please don't attempt to provide alternative > solutions if you don't undestand the actual problem. > And I'll simplify my question: > How to read form the compiled exe file resources used in a form by its > controls? (like a bitmap).
I think VB just stores the entire FRX file, not as separate image resources, so you have to decode it somehow, which is a lot of work. I read the other thread, which seems that you have images, and your OCX users could create multiple instances of the control, but you want these controls to share the images to save memory. I am not sure if the images are supplied by you, or by your users. If they are supplied by you, you can put them as a resource in the OCX, and load them at run time. I am not sure if LoadResPicture Function uses the OCX or the EXE, but you can use GetModuleHandle() to get a handle to the OCX, then use LoadImage() to load the picture from the OCX resource. If the images are provided by the user, then it's better to use separate files, such as BMP files. You can't save them into the OCX, because one of your users could replace the OCX of another user, replacing the images in the process. You can save the pictures in the user's EXE. In this case, binary property's are saved in FRX files in the user's project. You can store these pictures in global variables, and do a comparison and store only if the data is unique. Global variables in standard modules are accessible by all instances of your control. Try this for instance: In Module1: Public CreatedCounter As Long In UserControl: Private Sub UserControl_Initialize() CreatedCounter = CreatedCounter + 1 MsgBox "CreatedCounter = " & CreatedCounter End Sub For pictures, you can use a Collection to store file names, or use a dynamic array of StdPicture.
|
Sat, 26 Mar 2011 09:10:51 GMT |
|
 |
Eduard #15 / 25
|
 How to load resorces of a form that is not loaded
Quote: > I've given you the best advice I can think of given what I understand of > the issue. If that's not good enough for you, I guess you just have to > hope somebody else will reply that can offer that "other way".
Thank you for the best advice you can think, but it didn't answer my question. You tried to provide an alternative solution without undestanding the actual problem. I'll try to explain the problem here, but I'll do it later. If you want to help, tell me what you know (and if you would like to share with me) how the form's resources are stored in the exe. Thanks.
|
Sat, 26 Mar 2011 09:18:38 GMT |
|
|
Page 1 of 2
|
[ 25 post ] |
|
Go to page:
[1]
[2] |
|