From: beginner on 20 Nov 2007 07:53 In article <67b9276e-b036-4bfe-9f66-2a038d90342a(a)d50g2000hsf.googlegroups.com>, Mike Williams <gagamomo(a)yahoo.co.uk> wrote: >On 20 Nov, 06:13, not.t...(a)address.spam.no (beginner) wrote: > >> I intend to recognise the presence of Vista by >> seeing the presence of C:\WINDOWS\vistawuredir.cab >> or C:\Applications\oem\Vista_Manual_EN.pdf > >Why C:\? This does not work either, for whatever reason. I will look for some other files which give away that the operating system is Vista or XP. > >> and then giving a different sequence to SendKeys. >> Does that make sense? > >No. What would make sense to me would be to do the job without getting >MS Paint involved at all, perhaps using the code at the link we have >already posted for you. If MS Paint exposed some reliable and >documented functions then it would be fine to use them in your app, >but it does not do so and the method you are using of "hitting keys" >in your code in the hopes that those specific keystrokes suit whatever >version of Paint happens to be installed does not make sense at all to >me. You have a point. > >In fact, if you want 4 bit (16 colour) bmp files then it would make >sense to save them in that format initially, rather than creating them >as 24 bit full colour bitmaps and then converting them. That will be too messy to do from VB. I am storing plots of various kinds as pictures. >Such a task >would of course require fairly heavy use of the various Windows API >functions, which you have said you don't really want to use, but you >will be helped greatly in that task if you study the code at the links >we have already posted. If it is too advanced, I won't understand it and won't learn much anyway. I have to learn to crawl before I learn to run. > >By the way, what is it you are doing that requires only a 4 bit (16 >colour) bitmap? Can you explain exactly what these images are, and >what their purpose is? The reason I ask is that it is likely that >something other than a bmp format might better suit your needs. These are typically plots of a few variables - say temperatures at a few locations, flow rates, concentrations as functions of other variables like time. I would like the few curves in different colours but the actual colours don't matter, so I use QBColor(k), k = 1 to 12. BMP is never really the best format for this kind of pictures, but when code was written in VB 3, the only way to store pictures by SavePicture was to put them in bmp's. > >Mike >
From: Mike Williams on 20 Nov 2007 10:18 On 20 Nov, 12:53, not.t...(a)address.spam.no (beginner) wrote: > If it is too advanced, I won't understand it and > won't learn much anyway. I have to learn to crawl > before I learn to run. Well, you're quite right there, and in that case you might for the time being like to stick with your current method of creating your bitmaps with SavePicture and then converting them to 4 bit (16 colour) separately. However, I would strongly suggest that you use the code at the link we posted to perform the conversion, instead of messing about sending keystrokes to MS Paint. I know that at the moment you don't want to get too involved with things you don't yet understand, but the code to perform such conversions has already been written for you and you can place it in a module or something and then simply treat it like a "black box", where you pass it a full colour bitmap and it churns out a 16 colour bitmap file for you. We all use these "black boxes" from time to time, often without knowing how they go about their business and being content to simply know what inputs we need to give it in order to achieve our desired output. In fact, when you think about it, that is exactly the way you are currently treating MS Paint, as a black box the inner working of which you do not understand. And if MS Paint was an application that exposed its methods to VB (as many other applications are capable of doing) then I would be quite happy with you continuing to use it. But it doesn't, and it requires you to mess about sending it keystrokes that may or may not perform the required task depending on all sorts of factors that are often largely out of your control. So, all you would be doing if you follow my suggestion is moving from using the "MS Paint black box" (which is unreliable) to the "black box at the link we posted" (which is reliable and fully under your control). > These are typically plots of a few variables > - say temperatures at a few locations, flow > rates, concentrations as functions of other > variables like time. I would like the few > curves in different colours but the actual > colours don't matter, so I use QBColor(k), > k = 1 to 12. BMP is never really the best > format for this kind of pictures, but when > code was written in VB 3, the only way to > store pictures by SavePicture was to put > them in bmp's. Well the bit about SavePicture being able to save only bitmaps is still true today, even in VB6, when you are talking about images that you have drawn into a picture box in your code (lines, circles, arcs, graphs, whatever). If you want to draw and save such pictures in some other format then you need to use some other method to do so. For your particular requirements I would suggest using metafiles (specifically an .emf file) because the size of such files will be very much smaller even than your 16 colour bitmaps and of course they will allow you to use as many colours as you like and they will also draw smoothly onto any device, with the output on a printed page being very smooth, unlike the rather "jagged" curves and circles and things a printed bitmap would produce. There are of course no native VB functions for creating such metafiles and so you would require fairly heavy use of the various API functions, but the effort would be worth it. I realise that you still have lots of standard VB programming to pick up yet and metafiles are not something you want to consider at the moment, but it would be a good idea to think about them at some time in the future, especially for tasks such as this. In the meantime, and in the light of what you have said, I would suggest sticking to your existing "create a full colour bitmap and convert it later to 16 bit" method, but to simply switch the "black box" you are using from the "MS Paint black box" to the "black box code at the link we posted" ;-) Otherwise, if you just want to stick to using MS Paint and if you really do only want your code to work on the one single machine on which you have it working at the moment, or perhaps on your two other specific machines once you get it working on them, then feel free to do so. Mike
From: beginner on 21 Nov 2007 03:37 In article <ece6e0fc-5b0a-44f6-a615-8d935d38c9d7(a)v4g2000hsf.googlegroups.com>, Mike Williams <gagamomo(a)yahoo.co.uk> wrote: >On 20 Nov, 12:53, not.t...(a)address.spam.no (beginner) wrote: > >> If it is too advanced, I won't understand it and >> won't learn much anyway. I have to learn to crawl >> before I learn to run. > >Well, you're quite right there, and in that case you might for the >time being like to stick with your current method of creating your >bitmaps with SavePicture and then converting them to 4 bit (16 colour) >separately. However, I would strongly suggest that you use the code at >the link we posted to perform the conversion, instead of messing about >sending keystrokes to MS Paint. If you mean the page on vbaccelerator, I saw it. It is overkill and does not quite serve my purpose. It will try to cleverly simulate the right colours, and I don't want that. It is better to replace a complicated colour with a simpler colour. I want to learn how to use SendKeys, and it is not working well on XP either, which means I have more to learn. If not Paint, I could try Microsoft Photo Editor, but that does not have 4 bit bmp's. I could instead take RLE which should be even more effective when there is very little on the picture other than the background colour. Photo Editor could also have different versions, but I can copy the version I have here to the other two machines. > >I know that at the moment you don't want to get too involved with >things you don't yet understand, but the code to perform such >conversions has already been written for you and you can place it in a >module or something and then simply treat it like a "black box", where >you pass it a full colour bitmap and it churns out a 16 colour bitmap >file for you. > >We all use these "black boxes" from time to time, often without >knowing how they go about their business and being content to simply >know what inputs we need to give it in order to achieve our desired >output. > >In fact, when you think about it, that is exactly the way you are >currently treating MS Paint, as a black box the inner working of which >you do not understand. I agree completely. >And if MS Paint was an application that exposed >its methods to VB (as many other applications are capable of doing) >then I would be quite happy with you continuing to use it. But it >doesn't, and it requires you to mess about sending it keystrokes that >may or may not perform the required task depending on all sorts of >factors that are often largely out of your control. > >So, all you would be doing if you follow my suggestion is moving from >using the "MS Paint black box" (which is unreliable) to the "black box >at the link we posted" (which is reliable and fully under your >control). I could try Microsoft Photo Editor. But I want to learn to use SendKeys also, and there is no harm in writing code which will work on three different versions of Paint. > >> These are typically plots of a few variables >> - say temperatures at a few locations, flow >> rates, concentrations as functions of other >> variables like time. I would like the few >> curves in different colours but the actual >> colours don't matter, so I use QBColor(k), >> k = 1 to 12. BMP is never really the best >> format for this kind of pictures, but when >> code was written in VB 3, the only way to >> store pictures by SavePicture was to put >> them in bmp's. > >Well the bit about SavePicture being able to save only bitmaps is >still true today, even in VB6, when you are talking about images that >you have drawn into a picture box in your code (lines, circles, arcs, >graphs, whatever). If you want to draw and save such pictures in some >other format then you need to use some other method to do so. I would be interested in learning that also some time, but I am not taking a course now, nor do I have so much time that I can spend half of the working day learning a lot of advanced stuff on VB, which is not quite related to my normal work. > >For your particular requirements I would suggest using metafiles >(specifically an .emf file) because the size of such files will be >very much smaller even than your 16 colour bitmaps and of course they >will allow you to use as many colours as you like and they will also >draw smoothly onto any device, with the output on a printed page being >very smooth, unlike the rather "jagged" curves and circles and things >a printed bitmap would produce. This would be wonderful. I have never used .emf files or other metafiles, but that would be good to learn. Would I be able to easily include such pictures in Word or PowerPoint or OpenOffice? >There are of course no native VB >functions for creating such metafiles and so you would require fairly >heavy use of the various API functions, but the effort would be worth >it. I realise that you still have lots of standard VB programming to >pick up yet and metafiles are not something you want to consider at >the moment, but it would be a good idea to think about them at some >time in the future, especially for tasks such as this. I think so too. In the >meantime, and in the light of what you have said, I would suggest >sticking to your existing "create a full colour bitmap and convert it >later to 16 bit" method, but to simply switch the "black box" you are >using from the "MS Paint black box" to the "black box code at the link >we posted" ;-) There are also other such black boxes available. As far as possible, I don't want to add to my code things I don't understand, and if it is only *.exe, then I will prefer to use whatever is already there than download third party programs. > >Otherwise, if you just want to stick to using MS Paint and if you >really do only want your code to work on the one single machine on >which you have it working at the moment, or perhaps on your two other >specific machines once you get it working on them, then feel free to >do so. > >Mike > Paint is not the most important thing. I want to reduce the size of my 24 bit bitmaps without losing sharpness (losing colour is fine). I also want to learn to use SendKeys because that will open up a lot of other possibilities to run other related code, and a lot of command line stuff. SendKeys should work on Vista also, but it seems to require something. At present I don't even understand why it does not work on XP.
From: Mike Williams on 21 Nov 2007 08:03 On 21 Nov, 08:37, not.t...(a)address.spam.no (beginner) wrote: > If you mean the page on vbaccelerator, I saw it. > It is overkill and does not quite serve my purpose. > It will try to cleverly simulate the right colours, > and I don't want that. Personally I think you've come to your decision before you've considered the evidence and you've buried your head so far into the sand on this that you're refusing to see things you do not wish to see. I've just created half a dozen full colour (24 bit) bmp files in MSPaint, in each case using less than 16 different and randomly chosen colours. I then loaded the full colour bmps into MSPaint and saved them as 16 colour (4 bit) bitmap files. I then loaded the same full colour (24 bit) bmp files into the VBAccelerator code and saved them from there as 16 colour (4 bit) bmp files using the default setting. In each case the output from VBAccelerator was exactly the same as the output from MSPaint. In fact BOTH MSPaint and VBAccelerator messed up the colours, both in exactly the same way, because they both used the same standard 16 colour palette which did not contain the exact colours I had used in the original full colour bitmaps. However, if I restrcicted myself to using just the "bog standard" colours for the lines and fills in my full colour 24 bit bitmap and then converted to 16 colour (4 bit) bmps then both MSPaint and the VBAccelerator code faithfully reproduced those colours when converting the bitmaps to 4 bit (16 colours). All of that behaviour is in fact exactly what I would have expected, and it shows that using MSPaint is not going to give you something that other methods cannot. In fact, the opposite is true and if you move away from your idea of using MSPaint (see later in this response) you will have full control over the ouput. > I want to learn how to use SendKeys, and it > is not working well on XP either, which means > I have more to learn. Well that's not what you actually wanted in the first place. In your very first post you said, "Could someone show me how I could write a little code to open 'A.bmp' in Paint, and save it from Paint in 16 colours by using SendKeys or some better way?". So, your original task was to convert the bitmap, and Sendkeys was secondary to that task. Well, I've been trying to show you the "better way". In any case, controlling third party applications from VB using SendKeys should (in my opinion) be regarded as "the last option" and should only be used when there is no better way of doing the job. > If not Paint, I could try Microsoft Photo Editor, > but that does not have 4 bit bmp's. My advice would be to use neither of those programs. > I could instead take RLE which should be > even more effective when there is very > little on the picture other than . . . I would advise you to stay away from RLEs. They are not commonly used these days and in any case the format of a RLE is more complex than the format of a 4 bit bitmap, and if (as it appears) you are having trouble with 4 bit bmps then you'll have even more trouble with RLEs. If you want very low file sizes for your drawings coupled with very flexible content then metafiles are the way to go, but if (as you say) you want to fully understand all the things that you do then metafiles are a quite a way "in the future" for you at the moment, because they involve heavy use of the API functions that you have said you are not yet ready to deal with. > I could try Microsoft Photo Editor . . . and > there is no harm in writing code which will > work on three different versions of Paint. > Photo Editor could also have different versions, > but I can copy the version I have here to the > other two machines. Don't go down that road. You're just digging a hole for yourself, and it is totally unnecessary. > This would be wonderful [metafiles] I have > never used .emf files or other metafiles, > but that would be good to learn. Would I be > able to easily include such pictures in Word > or PowerPoint or OpenOffice? Yes. If you ever feel that you have the time to learn to create these metafiles then post again. You really do need a lot of time to spare if you want me to explain fully how it all works of course. A lot of API stuff is required, and you cannot use any native VB drawing methods at all. > I don't want to add to my code things > I don't understand But you've already done it! You've added MSPaint, and you do not understand how MSPaint works. All you know is "what goes in and what comes out". Anyway, having said all that, it appears that your requirement is to draw (or load) some bitmaps (graphs and things) into a VB Picture Box using standard VB drawing code (Line, Circle, etc, etc) using a maximum of 16 individual colours in the drawing and that you've already got that part of it "off the ground" and all you want to do now is to save those images as 4 bit (16 colour) bitmaps without using any API functions a\nd using only standard VB code? We've been on this subject so long now that I've half forgotten, but can you confirm that is exactly what you want to do? If so, and if you are prepared to move away from this "MSPaint" business and also from the "Sendkeys" business (neither of which are actually required to perform the task) then I'll show you how to do it using nothing other than standard VB commands in such a way that it allows you to use any colour you wish (as long as there are no more than 16 of them) and in a way that exactly preserves every single one of the 16 colours used in the drawing. You'll need to devote a bit of time to it of course, but not an excessive amount. The conversion to a 4 bit bmp will be relatively slow if you really do not want to use even a single API function (probably about 2 seconds for an 800 x 600 pixel bitmap), but it will definitely work and it will produce a more accurate output than MSPaint does. Do you want to do that? Also, if you are prepared to include just a couple of fairly straightforward API functions later, after you have mastered the general technique without them, you will be able to increase the speed to probably a hundred times faster. Are you interested in doing that? You'll have to wait a little while if you are though, because I've got lots of other things on at the moment and I haven't written the code myself yet - I just know how to go about it - so you'll need to bear with me. Otherwise, if you want to stick to MSPaint and SendKeys then you might like to start another thread so that someone else picks it up. Mike
From: beginner on 23 Nov 2007 04:03 In article <9c488870-f7a8-4f4d-8506-5bd4cc092b47(a)b15g2000hsa.googlegroups.com>, Mike Williams <gagamomo(a)yahoo.co.uk> wrote: >On 21 Nov, 08:37, not.t...(a)address.spam.no (beginner) wrote: > >> If you mean the page on vbaccelerator, I saw it. >> It is overkill and does not quite serve my purpose. >> It will try to cleverly simulate the right colours, >> and I don't want that. > >Personally I think you've come to your decision before you've >considered the evidence and you've buried your head so far into the >sand on this that you're refusing to see things you do not wish to >see. I don't think so, but it is possible that I got the wrong impression. >I've just created half a dozen full colour (24 bit) bmp files in >MSPaint, in each case using less than 16 different and randomly chosen >colours. I then loaded the full colour bmps into MSPaint and saved >them as 16 colour (4 bit) bitmap files. I then loaded the same full >colour (24 bit) bmp files into the VBAccelerator code and saved them >from there as 16 colour (4 bit) bmp files using the default setting. >In each case the output from VBAccelerator was exactly the same as the >output from MSPaint. In fact BOTH MSPaint and VBAccelerator messed up >the colours, both in exactly the same way, because they both used the >same standard 16 colour palette which did not contain the exact >colours I had used in the original full colour bitmaps. That page, however, talks about the colour reduction algorithms and show a picture with lossless compression, which seems to imply that they are doing something more than just replace a pixel colour with a simpler colour. However, if I >restrcicted myself to using just the "bog standard" colours for the >lines and fills in my full colour 24 bit bitmap and then converted to >16 colour (4 bit) bmps then both MSPaint and the VBAccelerator code >faithfully reproduced those colours when converting the bitmaps to 4 >bit (16 colours). All of that behaviour is in fact exactly what I >would have expected, and it shows that using MSPaint is not going to >give you something that other methods cannot. In fact, the opposite is >true and if you move away from your idea of using MSPaint (see later >in this response) you will have full control over the ouput. > >> I want to learn how to use SendKeys, and it >> is not working well on XP either, which means >> I have more to learn. > >Well that's not what you actually wanted in the first place. In your >very first post you said, "Could someone show me how I could write a >little code to open 'A.bmp' in Paint, and save it from Paint in 16 >colours by using SendKeys or some better way?". So, your original task >was to convert the bitmap, and Sendkeys was secondary to that task. OK. There are several things I am trying to do, but none of them are with any rigid priorities which is why my standpoint varies with time. I am interested in the "better way" also. From all this discussion, it looks like SendKeys is not a good thing to learn or use, so I can forget about it, and may be learn some alternatives. >Well, I've been trying to show you the "better way". In any case, >controlling third party applications from VB using SendKeys should (in >my opinion) be regarded as "the last option" and should only be used >when there is no better way of doing the job. OK. Are there better ways of running other programs from VB? > >> If not Paint, I could try Microsoft Photo Editor, >> but that does not have 4 bit bmp's. > >My advice would be to use neither of those programs. OK. > >> I could instead take RLE which should be >> even more effective when there is very >> little on the picture other than . . . > >I would advise you to stay away from RLEs. They are not commonly used >these days and in any case the format of a RLE is more complex than >the format of a 4 bit bitmap, and if (as it appears) you are having >trouble with 4 bit bmps then you'll have even more trouble with RLEs. OK. >If you want very low file sizes for your drawings coupled with very >flexible content then metafiles are the way to go, but if (as you say) >you want to fully understand all the things that you do then metafiles >are a quite a way "in the future" for you at the moment, because they >involve heavy use of the API functions that you have said you are not >yet ready to deal with. I don't have problems learning new things, and APIs seem a bit advanced but I can learn that as well. I actually read up about metafiles yesterday, and it seems to be good. > >> I could try Microsoft Photo Editor . . . and >> there is no harm in writing code which will >> work on three different versions of Paint. >> Photo Editor could also have different versions, >> but I can copy the version I have here to the >> other two machines. > >Don't go down that road. You're just digging a hole for yourself, and >it is totally unnecessary. OK. > >> This would be wonderful [metafiles] I have >> never used .emf files or other metafiles, >> but that would be good to learn. Would I be >> able to easily include such pictures in Word >> or PowerPoint or OpenOffice? > >Yes. If you ever feel that you have the time to learn to create these >metafiles then post again. You really do need a lot of time to spare >if you want me to explain fully how it all works of course. A lot of >API stuff is required, and you cannot use any native VB drawing >methods at all. I will not have a hell of a lot of time but I can always start to learn. I have no deadlines and nothing is waiting because I am not able to reduce bmp files, so I can comfortably learn at my own pace. Please do not spend too much of your time explaining me in detail. It would be good to tell me of some Internet sites where I can read up, and some keywords I should understand. > >> I don't want to add to my code things >> I don't understand > >But you've already done it! You've added MSPaint, and you do not >understand how MSPaint works. All you know is "what goes in and what >comes out". > >Anyway, having said all that, it appears that your requirement is to >draw (or load) some bitmaps (graphs and things) into a VB Picture Box >using standard VB drawing code (Line, Circle, etc, etc) using a >maximum of 16 individual colours in the drawing and that you've >already got that part of it "off the ground" and all you want to do >now is to save those images as 4 bit (16 colour) bitmaps without using >any API functions a\nd using only standard VB code? We've been on this >subject so long now that I've half forgotten, but can you confirm that >is exactly what you want to do? I am very flexible. Even my objectives are flexible. The main thing I am aiming at is learning while also doing something that could be useful to me. I don't need to avoid APIs if they are worthwhile, but a lot of people seem to use API even when the same thing can be done in a couple of lines in VB less efficiently. For me, simplicity of the code will take preference until I am a more advanced beginner. Yes, I would like to store pictures in relatively small space (not as much bmp or tiff consumes). The pictures are typically technical material - plots or schematic diagrams, where the actual colour is not terribly important. I will try to read more about .emf files also. > >If so, and if you are prepared to move away from this "MSPaint" >business and also from the "Sendkeys" business (neither of which are >actually required to perform the task) then I'll show you how to do it I have no compulsion to use Paint or SendKeys. I am curious if there is a good alternative to SendKeys. How do I run other programs from VB? >using nothing other than standard VB commands in such a way that it >allows you to use any colour you wish (as long as there are no more >than 16 of them) and in a way that exactly preserves every single one >of the 16 colours used in the drawing. This is interesting. >You'll need to devote a bit of >time to it of course, but not an excessive amount. The conversion to a >4 bit bmp will be relatively slow if you really do not want to use >even a single API function (probably about 2 seconds for an 800 x 600 >pixel bitmap), but it will definitely work and it will produce a more >accurate output than MSPaint does. Do you want to do that? I would like to learn how to do it without APIs, as well as how to do it with APIs, and what the major differences are. If you refer me to some Internet sites, I can print them out and read when I can. >Also, if >you are prepared to include just a couple of fairly straightforward >API functions later, after you have mastered the general technique >without them, you will be able to increase the speed to probably a >hundred times faster. Yes and no. Yes, because I have already used gdi, gdi32 without understanding what it does, and the no part - speed is not an issue for me. I have one machine running NT on 400 MHz, and I have a command in one of my VB programs to "slow down" calculations so that I can follow what is happening in the calculations. On my new machine, even the "slow down" command is not effective enough - I will write some more code to slow it down nicely. Are you interested in doing that? You'll have to >wait a little while if you are though, because I've got lots of other >things on at the moment and I haven't written the code myself yet - I >just know how to go about it - so you'll need to bear with me. There is no hurry, and please do not write the code for me. That is not a good way to teach someone. Tell me instead the commands I should read up about, or the APIs I should read up about, and I will try and succeed, or fumble for a while before I will come back and ask here. > >Otherwise, if you want to stick to MSPaint and SendKeys then you might >like to start another thread so that someone else picks it up. > >Mike > > > > >
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: User Defined Data Type --- Please HELP!!!! Next: Multiple icons in exe |