I am developing one application and i have added one button (CButton) which is calling SHBrowseForFolder() function. But the problem is that the button is still active and also it is letting me to click my parent window. Also i can click again and again that button and multiple browsing window are coming.
What i want to know that is there any way to use SHBrowseForFolder() in a DoModal() way, so that the control did not return to the parent window till user click that Ok/Cancel button of the folder browse window? I do not want to disable that button after clicking once or something like that.
I am using Visual Studio 2010.
Thanks in advance.
Sure it's possible:
void CUtility::BrowseFolder(CWnd* pParentWnd, const CString& sTitle, CEdit& Edit)
{
LPMALLOC pMalloc = NULL;
::SHGetMalloc(&pMalloc);
TCHAR pBuffer[MAX_PATH] = {0};
LPITEMIDLIST pidlRoot = NULL;
BROWSEINFO bi;
bi.hwndOwner = pParentWnd->m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = pBuffer;
bi.lpszTitle = sTitle;
bi.ulFlags = BIF_USENEWUI;
bi.lpfn = NULL;
if((pidlRoot = ::SHBrowseForFolder(&bi)) == NULL)
return;
if(::SHGetPathFromIDList(pidlRoot, pBuffer))
Edit.SetWindowText(pBuffer);
if(pidlRoot)
pMalloc->Free(pidlRoot);
}
Related
I want to create a dialog with a custom layout and no title. Also, the dialog should open on the top right corner of the screen. Here is the screenshot of what I want.
In xamarin.iOS is something like PopOverViewContainer. May it's in Android the same.
Maybe by changing the gravity of the dialog using the WindowManager Attributes property:
Android.App.AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
AlertDialog alertName = builder.Create();
alertName.SetTitle("Warning...");
alertName.SetIcon(Android.Resource.Drawable.IcDialogAlert);
alertName.SetMessage("This is a warning message");
alertName.SetButton("OK", (s, ev) =>
{
return;
});
alertName.Show();
var window = alertName.Window;
var wlp = window.Attributes;
wlp.Gravity = GravityFlags.Top;
wlp.Flags = WindowManagerFlags.DimBehind;
window.Attributes = wlp;
You should be able to change the gravity parameter and the flags (which currently stops the background to the dialog from dimming
I have used below code to achieve my requirement.
Window window = dialog.Window;
WindowManager.LayoutParams wlp = window.Attributes;
wlp.Gravity = GravityFlags.Top | GravityFlags.Right;
window.Attributes = wlp;
I have just started coding a simple windows form, but when I compile it the buttons/textboxes does not display.
Only a blank window pops up.
It looks like there is nothing in your InitializeComponent function.
Add this code in the function and you should see a button with "Connect" written on it.
private void InitializeComponent()
{
System.Windows.Forms.Button ConnectBtn = new System.Windows.Forms.Button();
ConnectBtn.Location = new System.Drawing.Point(10, 10);
ConnectBtn.Name = "ConnectBtn";
ConnectBtn.Size = new System.Drawing.Size(75, 23);
ConnectBtn.Text = "Connect";
this.Controls.Add(ConnectBtn);
}
hi i have created a user control.
now i want to add this control to a page e.g. when the user clicks a button (important is, that i dont want to add it direcly in xaml, i want to add id in the c# code section)
how to so this?
In your button's Click event, you could do something like:
MyControl control = new MyControl();
// Set whatever properties you need in your control here
LayoutRoot.Children.Add(control);
if (listBox1.Items.Count == 0)
{
Popup popup = new Popup();
WPCpopup po = new WPCpopup(popup);
popup.Width = System.Windows.Application.Current.Host.Content.ActualWidth;
popup.Child = po;
popup.VerticalOffset = 300;
popup.IsOpen = true;
}
WPCpopup is usercontrol
What I want is that whenever I choose a certain index in my ComboBox a certain panel will become visible.
So Here is What I've done:
I've created a ComboBox
I've created 2 Panels
I've set the visibility of the 2 Panels in their properties tab to FALSE
However I was not able to set them to visible when somebody selects something on my ComboBox.
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox3.SelectedIndex == 0)
{
panel9.Visible();
}
}
Note: I've docked the 2 Panels in the same GroupBox.
What's wrong with my code T_T. It says non vocable member. :((
EDIT** I have a new problem. Everytime I pick another option. The panel which has been set to visible won't get back to hidden.
It will appear when I choose Index 1 but when I choose Index 2 it will also appear o.O?
It says non invocable member as you are calling visible, which is a property, as a method when you place the () after it. Just set the property to a value as below
panel9.Visible = true;
It should be panel9.Visible = true;
In that case just do something like this
if(index == 1)
{
panel9.Visible = true;
panel10.visible = false;
}
else
{
panel9.Visible = false;
panel10.Visible = true;
}
I am doing a work that scans the barcode and gets the information behind it under windows mobile 6.5 and .net compact framework 2.0, using CameraCaptureDialog class to capture a picture from the phone camera, this is my code:
CameraCaptureDialog cameraCaptureDialog = new CameraCaptureDialog();
cameraCaptureDialog.Owner = this;
cameraCaptureDialog.Title = "";
cameraCaptureDialog.Mode = CameraCaptureMode.Still;
cameraCaptureDialog.InitialDirectory = dir;
cameraCaptureDialog.Resolution = new System.Drawing.Size(640, 480);
cameraCaptureDialog.DefaultFileName = "CodeBar.jpg";
if (cameraCaptureDialog.ShowDialog() == DialogResult.OK && cameraCaptureDialog.FileName.Length > 0)
{
curFileName = cameraCaptureDialog.FileName;
cameraCaptureDialog.Dispose();
}
//deal with CodeBar.jpg
the question is, during my code running, I have to press the capture button on the cameraCaptureDialog, then press the back button to return to my program to deal with the captured file, this operation needs to press 2 buttons, for user convenience, I want the cameraCaptureDialog to close automatically after the user pressed the capture button, how can this be done? as I know, when ShowDialog() method is called, cameraCaptureDialog won't return until the back button shown on the dialog, so I could do nothing before manually close the cameraCaptureDialog and the ShowDialog() method returned DialogResult.OK