How to Hide Title bar from VLC Media Player (VLC Direct 3d output)using LIBVLC in vc++ - libvlc

I am using libvlc in vc++.I want to hide the title bar from VLC Output Window(VLC 3D Direct OUTPUT). Can we hide or remove this title bar?

foreach (var handle in EnumerateProcessWindowHandles(Process.GetCurrentProcess().Id))
{
StringBuilder message = new StringBuilder(1000);
SendMessage(handle, WM_GETTEXT, message.Capacity, message);
if (message.ToString().Equals("VLC (Direct3D11 output)"))
{
var style = (SetWindowLongFlags)GetWindowLong(handle, WindowLongIndexFlags.GWL_STYLE);
style &= ~SetWindowLongFlags.WS_BORDER;
SetWindowLong(handle, WindowLongIndexFlags.GWL_STYLE, style);
}
}

Related

How do I convert the background of Edit Control to transparent in mFC VC++?

Output is show in picture
I am using one CStatic control with variable as "m_background" and ID as IDC_background. In this control, the video has been run on the click of the button. and there is second control Edit Control with variable as "m_edit" and ID as IDC_edit.This Edit Box is placed over static control. I want to show the text written in Edit Control on video while we play video on click of the button with transparent background color of EDit Control.
But the problem is grey/white background has appeared for m_edit control while we play video. I want to show the text on the video with transparent background of the "m_edit" control while we play the video.
BOOL CtestcodeDlg::OnInitDialog()//To set up the video in background and text above the video
{
m_background.ModifyStyle(0, WS_CLIPSIBLINGS);
m_edit.SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE|WS_EX_TRANSPARENT);
return TRUE; // return TRUE unless you set the focus to a control
}
HBRUSH CtestcodeDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) //To transparent the background of Edit box
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
HBRUSH m_default=CreateSolidBrush(RGB(0,0, 0));
if(pWnd->GetDlgCtrlID() == IDC_edit)
{
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkColor(TRANSPARENT);
pDC->SetBkMode(TRANSPARENT);
}
return hbr;
}
void CtestcodeDlg::OnBnClickedButton1()////To run the video
{
my_instance = libvlc_new(0, NULL);
my_media_file = libvlc_media_new_location(my_instance,
"rtsp://BigBuckBunny_115k.mov");
my_player = libvlc_media_player_new_from_media(my_media_file);
my_event_manager = libvlc_media_player_event_manager(my_player);
libvlc_media_player_play(my_player);
libvlc_audio_set_track(my_player ,-1);
libvlc_media_player_set_hwnd(my_player, m_background);
Sleep(1000);
_beginthread(test, 0, NULL);
libvlc_audio_set_track(my_player ,-1);
}
Try using SetLayeredWindowAttributes function, with the crKey of your bk color.
Also, i think pDC->SetBkColor(TRANSPARENT); in your code is a mistake, it sets bk color to black. Try to run without this call.

Change swipe to delete button height in UITableview in Xamarin IOS

I have a table view with cells having some padding around them. I implemented swipe to delete feature and by default the delete button occupies the cell height.
I used below code for IOS 10 to align it with the visible cell height and it is screwing up the button height in a wierd way. Note : I have got it working fine in IOS 11 using a different set of code as the way to handle this is different between IOS 10 and IOS 11.
But below code for IOS 10 screws up button height. Looks like the layout subview gets called multiple times when user swipes and that is causing the button height to vary a lot. Any ideas of how to solve this.
public override void LayoutSubviews()
{
base.LayoutSubviews();
if (Convert.ToInt16(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]) < 11)
{
foreach (var view in this.Subviews)
{
if (view.Class.Name.ToString() == "UITableViewCellDeleteConfirmationView")
{
CGRect newFrame = view.Frame;
newFrame.Y = newFrame.Y + 6;
newFrame.Height = newFrame.Height - 12;
view.Frame = newFrame;
}
}
}
}
Refer to this post.
The view hierarchy before iOS11 demonstrates as below
UITableView -> UITableViewCell -> UITableViewCellDeleteConfirmationView -> _UITableViewCellActionButton
I see you get the UITableViewCellDeleteConfirmationView not the Button .
Modify your code :
foreach (UIView subview in this.Subviews)
{
if (subview.Class.Name.ToString() == "UITableViewCellDeleteConfirmationView")
{
foreach (var view in subview.Subviews)
{
if (view.Class.Name.ToString() == "_UITableViewCellActionButton")
{
CGRect newFrame = view.Frame;
newFrame.Y = newFrame.Y + 6;
newFrame.Height = newFrame.Height - 12;
view.Frame = newFrame;
}
}
}
}

MFC menu is not drawing but white blank

Im working on some Window Customizing stuff.
I removed title bar and border of CFrameWnd and added my own title bar.
It seems work nice.
But if I add menu to this window, menu will be on top of this window. (above my title bar)
So I add new CFrameWnd and set my menu to this new CFrameWnd.
this is the code.
CMenu * pMenu = this->GetMenu();
if( pMenu != NULL )
{
this->SetMenu(NULL);
m_pMenuWnd = new CMenuWindow();
m_pMenuWnd->Create(NULL, NULL, 0, m_WindowRects.MenuRect, this, 0, NULL);
m_pMenuWnd->SetMenu(pMenu);
m_pMenuWnd->ShowWindow(SW_NORMAL);
}
And I added this menu window's move handler on my custom CFrameWnd's OnSize, OnMove Message Handler for corrent positionning.
It looks pretty good.
But when I minimize and restore its position, menu windows position is just white blank.
But if I move cursor on there, menus r there.
What am I doing wrong?
I checked OnCtlColor but its not even get called.
Here's CMenuWindow code
BEGIN_MESSAGE_MAP(CMenuWindow, CFrameWnd)
ON_WM_CREATE()
ON_WM_ACTIVATE()
ON_WM_KEYUP()
ON_WM_SYSKEYUP()
END_MESSAGE_MAP()
void CMenuWindow::OnDraw(CDC* pDC)
{
CRect clRect;
GetClientRect(&clRect);
}
// CMenuView message handlers
int CMenuWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
ModifyStyle(WS_CAPTION, WS_CLIPCHILDREN);
ModifyStyleEx(WS_EX_CLIENTEDGE,0);
return 0;
}

How to prevent screen rotation in j2me?

I'm programming in j2me.
How can I prevent screen rotation in j2me for all phones that support screen rotation?
thanks.
If you use Canvas to draw your screen (not LCDUI, not LWUIT, not any other framework) you may implement sizeChanged method to be notified when the rotation happens.
In such case you may draw your screen to an Image and use Sprite to rotate it. For example, to support only Landscape mode I used below code at constructor:
int width = Math.max(super.getWidth(), super.getHeight());
int height = Math.min(super.getWidth(), super.getHeight());
// screen and sprite are attributes
screen = Image.createImage(width, height);
sprite = new Sprite(screen);
if (super.getWidth() < super.getHeight()) { // portrait screen
sprite.setTransform(Sprite.TRANS_ROT90);
sprite.setPosition(0, 0);
}
And following methods:
public void sizeChanged (int w, int h) {
// lastWidth and lastHeight are attributes
lastWidth = w;
lastHeight = h;
if (sprite == null) return;
if (super.getWidth() < super.getHeight()) { // portrait screen
sprite.setTransform(Sprite.TRANS_ROT90);
} else {
sprite.setTransform(Sprite.TRANS_NONE);
}
sprite.setPosition(0, 0);
}
protected void paint(Graphics g1) {
if (super.getWidth() != lastWidth
|| super.getHeight() != lastHeight) {
sizeChanged(super.getWidth(), super.getHeight());
}
Graphics g = screen.getGraphics();
// ... do your drawing on g
this.sprite.setImage(screen, screen.getWidth(), screen.getHeight());
sprite.paint(g1);
}
As seen at http://smallandadaptive.blogspot.com.br/2009/08/fullscreen-landscape.html and http://smallandadaptive.blogspot.com.br/2010/03/adapting-to-sizechanged.html and http://smallandadaptive.blogspot.com.br/2011/04/sizechanged-not-called.html
Add to manifest
For Nokia devices:
Nokia-MIDlet-App-Orientation : Landscape
For Samsung devices:
MIDlet-ScreenMode : Landscape

displaying Wiki mobile page in UIWebView within UIPopoverController

I try to open wiki mobile version webpage by a UIWebView within a UIPopoverController. the problem is, not matter how I set my contentSizeForViewInPopover, or just UIWebView frame, or simply set UIWebView.scalesPageToFit = YES. the Wiki mobile version page content size seem to larger than my UIWebView. But if I use it on iPhone, there's no such problem. here's my code for popover controller:
//create a UIWebView UIViewController first
WikiViewController *addView = [[WikiViewController alloc] init];
addView.contentSizeForViewInPopover = CGSizeMake(320.0, 480.0f);
//then create my UIPopoverController
popover = [[UIPopoverController alloc] initWithContentViewController:addView];
popover.delegate = self;
[addView release];
//then get the popover rect
CGPoint pointforPop = [self.mapView convertCoordinate:selectAnnotationCord
toPointToView:self.mapView];
CGRect askRect = CGRectMake((int)pointforPop.x, (int)pointforPop.y+10, 1.0, 1.0);
[popover presentPopoverFromRect:askRect
inView:self.mapView
permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
[self.mapView deselectAnnotation:annotation animated:YES];
and this is my code on creating UIWebView:
- (void)viewDidLoad
{
wikiWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)];
wikiWebView.scalesPageToFit = YES;
//or No, doesn't matter, it all get larger than this
wikiWebView.delegate = self;
self.view = wikiWebView;
}
all code seem to be typical...
I wonder if anyone can shed me some light, thank you so much.
This is an enhanced version of auco answer, where if the viewport meta tag is not present it will be added:
- (void)webViewDidFinishLoad:(UIWebView*)webView
{
int webviewWidth = (NSUInteger)webView.frame.size.width;
if (!webView.loading) {
NSString *jsCmd = [NSString stringWithFormat:#"try {var viewport = document.querySelector('meta[name=viewport]');if (viewport != null) {viewport.setAttribute('content','width=%ipx, initial-scale=1.0, user-scalable=1');} else {var viewPortTag=document.createElement('meta');viewPortTag.id='viewport';viewPortTag.name = 'viewport';viewPortTag.content = 'width=%ipx, initial-scale=1.0, user-scalable=1';document.getElementsByTagName('head')[0].appendChild(viewPortTag);}} catch (e) {/*alert(e);*/}", webviewWidth, webviewWidth];
[webView stringByEvaluatingJavaScriptFromString:jsCmd];
}
}
Here is the Javascript pretty formatted code we are injecting in the WebView with a width of 320px
try {
var viewport = document.querySelector('meta[name=viewport]');
if (viewport != null) {
viewport.setAttribute('content',
'width=320px, initial-scale=1.0, user-scalable=1');
} else {
var viewPortTag = document.createElement('meta');
viewPortTag.id = 'viewport';
viewPortTag.name = 'viewport';
viewPortTag.content = 'width=320px,initial-scale=1.0, user-scalable=1';
document.getElementsByTagName('head')[0].appendChild(viewPortTag);
}
} catch (e) {
/*alert(e);*/
}
you can remove the try/catch if you want.
oh, i found in another QA that sometimes if html got a line "width=device-width", and you load a webview from popover controller, this popover controller will automatically send out device-width, not the view width you specified, and make your view ugly and funky. in that post it is a jQuery issue, and it solved with a jQuery way. In my problem, it is just a html issue in wiki mobile version. so I try another way, but similar.
I simple add a code in webViewdidload delegate method, first get URL html into a NSString, then use NSString instance method to search for "device-width" in loaded html, and replace it with my view width to make it a new NSString, then load this page with this new NSString. that's it.
- (void) webViewDidFinishLoad:(UIWebView *)webView
{
if (!alreadyReload)
{
NSString *webHTML = [NSString stringWithContentsOfURL:webView.request.URL encoding:NSUTF8StringEncoding error:NULL];
NSRange range = [webHTML rangeOfString:#"device-width"];
if ((range.location!=NSNotFound)&&(range.length != 0))
{
webHTML = [webHTML stringByReplacingOccurrencesOfString:#"device-width" withString:#"whatever width you need" options:0 range:range];
[webView loadHTMLString:webHTML baseURL:wikiWebView.request.URL];
alreadyReload = YES;
}
}
}
something like this.
by the way, since I only use this on wiki mobile version, the html is simple and this kind of compare and replace is pretty easy. if you wanna use it in a more general case, you might use other way.
It would be much more efficient to manipulate the device-width via JavaScript rather than altering the html after it has fully loaded and then reloading the full page with modified html again.
This should work (and also consider if it's even necessary to change the viewport width):
- (void)webViewDidFinishLoad:(UIWebView *)aWebView {
if(aWebView.frame.size.width < aWebView.window.frame.size.width) {
// width=device-width results in a wrong viewport dimension for webpages displayed in a popover
NSString *jsCmd = #"var viewport = document.querySelector('meta[name=viewport]');";
jsCmd = [jsCmd stringByAppendingFormat:#"viewport.setAttribute('content', 'width=%i, initial-scale=1.0, user-scalable=1');", (NSUInteger)aWebView.frame.size.width];
[aWebView stringByEvaluatingJavaScriptFromString:jsCmd];
}
// stop network indicator
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

Resources