Results 1 to 16 of 16

Thread: Usercontrol kick's ass

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Exclamation

    No it's not, it sux.- I have problems passing usercontrol reference:

    I have a module to handle certain drawing methods for several usercontrols in an ActiveX. What should i pass to the method so that i can use ie line method on it. Passing "Me" keyword or "Usercontrol" wont work. IE:

    In usercontrol:
    Code:
    Drawbox me ' <--- What to put here instead of me?
    In module:
    Code:
    Sub drawbox (obj as object)
    obj.line (0,0)-(obj.height-screen.twipperpixely,obj.width-screen.twipperpixelx),0,B
    end sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2

    Cool

    Hi kedaman...

    I once made an ActiveX control to replace these fat button with their borders. What I did was to draw 4 lines in the ActiveX form.

    IE:
    Code:
    Line (UserControl.Width - 30, 0)-(UserControl.Width - 30, UserControl.Height - 30), &H8000000D, B
    I don't really think the module is the best way... anyway, hope this helps.
    See you...

    keetsh®


  3. #3

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    No, i really want to share the the code between the usercontrols, i have some shared variables and statics in the module
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Rewrite the Sub in the BAS module to take the hDC as the argument instead of an object. Then use the API function LineTo instead. Then pass the hDC of the UserControl to your Sub.

    Good luck!

  5. #5

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    How do i use colors with Lineto api?
    Will it always start from (0,0)?
    How do i get the size of a DC?
    I still want to know if there's a way to pass the usercontrols reference.

    Here's another qwestion, how do i make an Enum to work both as arguments in public methods in modules and public variables in usercontrols?

    IE:
    In usercontrol:
    Code:
    property get Btnstate() as Buttonstate
    In module:
    Code:
    Enum Buttonstate
     Down=-1
     None=0
     Up=1
    End enum
    
    Sub drawbevel (obj as object, Btnstate as Buttonstate)
    .
    .
    I get an compile error on the usercontrol variable:
    Private Enum types cannot be used as parameter or return types for public procedures, or as public data members
    [Edited by kedaman on 05-13-2000 at 05:19 PM]
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Guest
    the easiest way would be to have a picture box that is set to fill the UserControl completly and pass the reference to the picturebox ...


  7. #7

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I know you can cheat that way, but don't want to. That way it will double the usage of user resources, and i'm working on a rollover effect button for usage both independent an in a toolbar, so i want to keep the res as low as possible.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Member
    Join Date
    May 2000
    Location
    USA-TEXAS-DALLAS
    Posts
    34
    Hey kedaman you seem like an awsome programmer.Right now i pretty much know nothing compared to you. How did you learn all of what you know? where is a good place i can start?
    -Jeff
    Using VB 6.0 Enterprise
    I Still like to program on my TI-85!

  9. #9
    Member
    Join Date
    May 2000
    Location
    USA-TEXAS-DALLAS
    Posts
    34
    Also would you like to see the program that im working on? And give me advice on how to better it?
    -Jeff
    Using VB 6.0 Enterprise
    I Still like to program on my TI-85!

  10. #10
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    I'm having a little difficulty understanding what you're trying to do but a couple of things are standing out.

    1) Can you not use a public enum?
    2) It seems like this module you are writing is an integral part of the usercontrols' functionality, in which case it should be compiled into the usercontrol (I maybe misunderstanding what you are trying to do though) can't you write a single module (or class) and include it in each of you usercontrols separately and compile them? then to init the effect you want you could just call that property or function of the control. It sounds like you are making a control then trying to modify it later!(like it's someone elses control which lacks the functionality you need) It's your control, can't you just design it with the functionality in the first place?

    Like I said, maybe I'm missing something

    Talk to ya later...



    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  11. #11
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Ked, you have 2 options,

    1 Put the code to draw the bevel inside the usercontrol, not in a module, If you want to do it in a module you're gonna have to give your controls a line method, and I don't know how to do that properly on VB5 or you could have a different line meathod that takes it's parameters like a normal function, ie Line X1,Y1,X2,Y2,Colour rather than Line (X1,Y1)-(X2,Y2) , Colour. or you could use the API drawing methods

    Get the size of the DC from

    A using select object to get it's bitmap handle (remember to put it back) then use GetObject to get it's size.

    B using the controls height and width properties.


    and you will need a public hDC property, so you don't get the luxury of not letting users draw on your window.

    to set the colour you need to create a brush using the create solid brushAPI, put it into the bitmap using select object (remember to delete the old brush)

    The line method is far easier, keep it in the usercontroll, how many usercontrolls have you got that you absolutley Need to share code?

  12. #12

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Jeb: Thanks, i learned trough pure experience in my past 7 years until i found this site, which have given me ten times more than i would find on any other vb-site. Just send you prg to [email protected] and i'll have a look at it.

    Paul: I'm working on my own controls here, By putting the enum in the usercontrol i got it work, but i don't like the idéa. Why can't i put a single enum in the module and let all usercontrols use it?

    ActiveX ocX Kedatoolbar
    Usercontrol Toolbar
    Usercontrol Kedabutton
    Module drawbevels

    Sam: i got the linemethod, but it crashed vb instantly. I want to leave this usercontrol drawing now, and move on to manipulating the DC, I shall try what you suggested, but have never user those brushes, can you give me some code. I have two usercontrols so far that share this, but i want to have use of this drawbevel method in other appz or usercontrols.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  13. #13

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    no SMALLBITMAP datatype found, i didn't find it in api text viewer either. what is it?
    Also how do i currentx, currenty on the DC? I have to move to a certain point before i use lineto

    btw, if you're online then use icq, we could discuss this
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  14. #14
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Code:
    Private Type SMALLBITMAP    'Does not contain all the
            bmType As Long      'Data members of a Bitmap
            bmSize As POINTAPI  'Just the first 12 bytes which all we need
    End Type                    'so we can get the height and width

    It's in the code there looking at you. It's not an API DataType, it's a BITMAP type I've Cut Down and changed to suit my needs.

  15. #15

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    OK, everything works fine but:

    I have the bevel drawn but the color is still black. The SetDCColour didn't work, or is it the lineto that don't work with setDCColour?

    Try for yourself:
    SetDCColour hDC, vbred
    LineTo hDC, width,height
    (this is just an example)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  16. #16

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    How about Setpixelv? will it be significanlty slower to use it in a for next than lineto?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width