customizing gui controls

Discussion in 'Effects and the DSP' started by stylus02, Jan 9, 2012.

  1. stylus02

    stylus02 New Member

    Joined:
    Jan 11, 2008
    Messages:
    283
    Likes Received:
    2
    Trophy Points:
    0
    there is no rush. :)
     
  2. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    OK, I tried it in kX and it worked pretty much as it is...

    The only problem I had was I could not really figure out a way to load the bitmap(s) stored in the skin in such a way that it loads as a ColorMappedBitmap (or DIBSection, which would work too (using SetDIBColorTable)). In any case, including the bitmaps as a resource (as in the example code) worked fine, so I just did that. You just need to change:
    Code:
    //from
    bmp = ::CreateMappedBitmap(AfxGetInstanceHandle(), m_iImagematrix, 0, ColorMap, 3);
    //to
    bmp = ::CreateMappedBitmap(GetModuleHandle("yourPlugin.kxl"), m_iImagematrix, 0, ColorMap, 3);
    
    You only need to add the MatrixStatic cpp and h files to your project, add an include for MatrixStatic.h and a CMatrixStatic variable to yourPlugin.h and create the control and set it's properties in yourPluginDlg's init.

    Picture
    Here are the files I used for testing...
     
    Last edited: Jan 14, 2012
  3. stylus02

    stylus02 New Member

    Joined:
    Jan 11, 2008
    Messages:
    283
    Likes Received:
    2
    Trophy Points:
    0
    have it working, great! without the new codeline i had only a black rectangle. some people on code project replied they had the same problem. (which driver version did you use? i still do it on 3545.)
     
  4. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    I have 3550 installed, but I think I used the 3548 SDK (mainly because I already had VCExpress setup for it).
     
  5. stylus02

    stylus02 New Member

    Joined:
    Jan 11, 2008
    Messages:
    283
    Likes Received:
    2
    Trophy Points:
    0
    @russ the display is integrated in the 120. i added some textfilter functionality (remap text, add spacer, autoscroll). the only thing i don't get right is the update of the -not scrolling- display text when a window overlappes. must have to do with the paint dc. everything else is fine.
     
    Last edited: Jan 20, 2012
  6. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Hmm, I do not have that problem so it is hard to say what might be wrong...

    Does the original demo project from CodeProject have that problem for you if you change one of them to not scroll?

    I tested with the original demo project and my test plugin (just commenting out the DoScroll lines, so it is set to not scroll) and I did not see any problems.

    How are you creating the controls? When you are using more than one, are you giving each one a different control ID?

    How much did you change to add your new functionality?
     
  7. stylus02

    stylus02 New Member

    Joined:
    Jan 11, 2008
    Messages:
    283
    Likes Received:
    2
    Trophy Points:
    0
    Last edited: Jan 20, 2012
  8. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    OK, I see a couple of problems.

    First, your bitmap has a 256 color palette (with (IIRC) 15 colors used). The original bitmaps were only 16 color (3 colors used). The code that changes the colors only changes the 1st 3 colors (and expects them to be in the correct order). Thus setting colors using your bitmap is not gonna work correctly (only 3 colors are gonna change and they are probably not gonna be the color you wanted to change). If you want it to work right with your bitmap, you would probably have to modify the code to change all 15 colors, but that would make using it more complicated (e.g. you have to set all 15 colors in code, etc).

    Also, your project uses the demo project and builds everything as demo.dll (later renamed). This is causing an issue with GetModuleHandle (i.e. if you keep it named demo.kxl (with GetModuleHandle("demo.kxl"), it seems to work correctly), but renaming it (and using the new name with GetModuleHandle) does not seem to work.

    With your bitmap you might just consider getting rid of the ability to change the colors in code since it is not gonna work correctly as it is right now (i.e. just use colors from the bitmap). That would eliminate the need to load it as a ColorMappedBitmap, and thus you would not have to include it as a resource (you could just load it from the skin), and would get rid of the need to use GetModuleHandle, etc.

    BTW: The "_T" is for string literals (not needed when you pass in a CString variable).
     
  9. stylus02

    stylus02 New Member

    Joined:
    Jan 11, 2008
    Messages:
    283
    Likes Received:
    2
    Trophy Points:
    0
    i fear you got an older source, sorry. the rename problem was known and fixed. tried out 16 colors (original bitmap), same problem. color changing is not needed so i could cut it out. loading the bitmap with the skin would be smart. all the colors can be done in a 2d graphic program. i really want use 8 or 24 bit to include some effects (lightning, reflections) that are already in the bitmap. new question is how to load and make it all work within CMatrixStatic/ iDemoPluginDlg?
    beside that: yesterday i've noticed, that i left out/ not included CMatrixStatic::OnPaint();return TRUE; (iDemoPluginDlg::init() )
    simple putting in brings errors (illegal call of a nonstatic member & void returns a value)

    (this problem has not that high priotity. what i have is a good starting point for a really nice looking gui.)

    something for your eyes guys, if you're bored from sourcecode- discussion. ;)
    https://sites.google.com/site/kxmodular/dry_impact_02_web.jpg?attredirects=0
     
    Last edited: Jan 21, 2012
  10. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Here are the changes I would probably do: Changes

    Removed the coloring stuff (except background (which defaults to black)).
    Removed the "large, small, tiny" stuff and just made the default size the tiny size (as that is what your bitmap uses). You can use SetSizes function to modify the sizes for other bitmaps (or modify the code).

    As for the "CMatrixStatic::OnPaint();return TRUE; (iDemoPluginDlg::init() )" stuff, I do not understand (I do not know what you intend to do with the above)... In any case, you should not need to call OnPaint, if you want to force a redraw, use Invalidate or RedrawWindow, etc.
     
  11. stylus02

    stylus02 New Member

    Joined:
    Jan 11, 2008
    Messages:
    283
    Likes Received:
    2
    Trophy Points:
    0
    the 2 lines must have happened while copy& paste from the original code project. they make no sense in that context. well, i should cleanup my working directories. i test your modifications still today.
     

Share This Page

visited