Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

non-mfc semi transparent control

Posted on 2006-07-13
5
Medium Priority
?
307 Views
Last Modified: 2008-02-01
hi experts,

i'm trying to create semi-transparent slider control.
the parent is a window which draws a map and i want the control to be displayed on top of it upon long press.
i don't even know how to start, i thought maybe using OnCustomDraw like in MFC but i got nowhere.

cheers
0
Comment
Question by:sedgwick
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 17098263
Use the following function SetWindowLong(...) and SetLayeredWindowAttributes(...)

Like this
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd, 0, 127.7, LWA_ALPHA);
0
 
LVL 42

Author Comment

by:sedgwick
ID: 17098908
i did it but i can't see the control at all.

let me explain the logic:
the control should be displayed upon long press on a button, after 2 seconds i create the control and on the Draw() function i show it.
when the user stop pressing the button, i count 3 seconds and hide the control.

here's my code:
void CDMainView::CreateVolumeSlider()
{
      CDButton* pBtn = m_MainScreen->GetButtonFromCtlID(IDC_MAINSCREEN_MUTE_BTN);

      RECT rcSlider, rc;
      pBtn->GetRect(rc);
      rcSlider = rc;
      rcSlider.bottom = rc.top+2;
      rcSlider.top = rcSlider.bottom+50;
      
//tell main screen to create the control
      m_MainScreen->CreateVolumeSlider(rcSlider);
}

void CNavMainScreen::CreateVolumeSlider(RECT& rcSlider)
{
      if(!VolumeSlider)
      {
            VolumeSlider = new CVolumeSlider();
            VolumeSlider->CreateWnd(this, rcSlider);

      }

      m_bShowVolumeSlider = true;
}

void CNavMainScreen::Draw()
{
.
.
.
//m_bShowVolumeSlider - wheather to show the control or not
//m_bVolumeSliderCountdown - wheather to start the 3 seconds countdown before hiding the control again

      if(m_bShowVolumeSlider)
      {
            if(m_bVolumeSliderCountdown)
            {
                  if(m_dwVolumeSliderTick == 0)
                        m_dwVolumeSliderTick = GetTickCount();
                  else
                  {
                        DWORD dw = GetTickCount();
                        if(dw-m_dwVolumeSliderTick > VOLUME_SLIDER_INTERVAL)
                        {
                              m_dwVolumeSliderTick = 0;
                              m_bShowVolumeSlider = false;
                              m_bVolumeSliderCountdown = false;
                        }
                  }
            }

            ShowVolumeSlider(m_bShowVolumeSlider);
      }

      RedrawWindow();
}

maybe the parent window doesn't get the message, i don't know why i can;t see it.

cheers
0
 
LVL 42

Author Comment

by:sedgwick
ID: 17099026
if i call CreateVolumeSlider() after user release the button (upon LButtonUp()) it works fine, but i want to display it while the user press the button for 2 seconds.
0
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 17100061
Create two message handlers:

One for Left  button down. Set a timer
void CNavMainScreen::OnLButtonDown(UINT nFlags, CPoint point)
{
      SetTimer(1, 2000, fnTimer); // fnTimer is the handler.
      CView::OnLButtonDown(nFlags, point);
}

void CALLBACK fnTimer(HWND, UINT, UINT, DWORD)
{
    // Do whatever you wnt to do
}

One for Left  button up . Set a timer
void CNavMainScreen::OnLButtonUp(UINT nFlags, CPoint point)
{
      KillTimer(1); // kill the timer if left button is released before 2 seconds
      CView::OnLButtonUp(nFlags, point);
}
0
 
LVL 12

Accepted Solution

by:
rajeev_devin earned 500 total points
ID: 17100069
>> One for Left  button up . Set a timer
Sorry, that would be kill the timer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question