Search Results

Search found 61 results on 3 pages for 'showwindow'.

Page 1/3 | 1 2 3  | Next Page >

  • Focus process window, ShowWindow vs System Tray

    - by ais
    I try open process window, this code work if window state is minimize, but if program in system tray window isn't opened. [DllImport("User32")] private static extern int SetForegroundWindow(IntPtr hwnd); [DllImport("User32")] private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); private static void ShowWindow(Process process) { ShowWindow(process.MainWindowHandle, SW_RESTORE); SetForegroundWindow(process.MainWindowHandle); }

    Read the article

  • ShowWindow not working from a DLL on a 64-bit OS?

    - by Auto Roast
    I have a process that calls SetWindowsHook to catch keyboard events. In the DLL that processes the events, I conditionally call ShowWindow on the handle of the window of the process who set the hook. That code works perfectly on a 32-bit OS (XP) and as a 32-bit application on a 64-bit OS, but when compiled to 64-bit, the window is not showing. The code to make the window visible is: if (idx == passlen) { HWND h = FindWindow(NULL,windowNameToShow); ShowWindow(h,SW_SHOW); idx = 0; logger->backerase(passlen - 1); nextCharToMatch = passPointer; }

    Read the article

  • Drawing problem does ShowWindow(hWnd, SW_HIDE) automatically invalidate rectangles?

    - by wk1989
    Hello, I'm running into a problem where, I have a Window that contains a child window. The child window contains another child window where a video is playing using Windows Media Player. Whenever I do call ShowWindow (hWnd, SW_HIDE) on the parent Window and paint over the entire surface, the region occupied by the grand-child window (where the video was playing) is not overridden. I used spy++ and found that that region which was not overridden was set to hidden BEFORE the repaint occurs. I monitored the hwnd of the grand-child window and it did not seem to receive any WM_EraseBKGND or WM_NCPAINT messages. Does this mean the area it occupied had not been invalidated and therefore could not be drawn over? I'm new to winforms. Thanks!

    Read the article

  • Dialog created after first becomes unresponsive unless created first?

    - by Justin Sterling
    After creating the initial dialog box that works perfectly fine, I create another dialog box when the Join Game button is pressed. The dialog box is created and show successfully, however I am unable to type in the edit box or even press or exit the dialog. Does anyone understand how to fix this or why it happens? I made sure the dialog box itself was not the problem by creating and displaying it from the main loop in the application. It worked fine when I created it that way. So why does it error when being created from another dialog? My code is below. This code is for the DLGPROC function that each dialog uses. #define WIN32_LEAN_AND_MEAN #include "Windows.h" #include ".\Controllers\Menu\MenuSystem.h" #include ".\Controllers\Game Controller\GameManager.h" #include ".\Controllers\Network\Network.h" #include "resource.h" #include "main.h" using namespace std; extern GameManager g; extern bool men; NET_Socket server; extern HWND d; HWND joinDlg; char ip[64]; void JoinMenu(){ joinDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_GETADDRESSINFO), NULL, (DLGPROC)GameJoinDialogPrompt); SetFocus(joinDlg); // ShowWindow(joinDlg, SW_SHOW); ShowWindow(d, SW_HIDE); } LRESULT CALLBACK GameJoinDialogPrompt(HWND Dialogwindow, UINT Message, WPARAM wParam, LPARAM lParam){ switch(Message){ case WM_COMMAND:{ switch(LOWORD(wParam)){ case IDCONNECT:{ GetDlgItemText(joinDlg, IDC_IP, ip, 63); if(server.ConnectToServer(ip, 7890, NET_UDP) == NET_INVALID_SOCKET){ LogString("Failed to connect to server! IP: %s", ip); MessageBox(NULL, "Failed to connect!", "Error", MB_OK); ShowWindow(joinDlg, SW_SHOW); break; }   } LogString("Connected!"); break; case IDCANCEL: ShowWindow(d, SW_SHOW); ShowWindow(joinDlg, SW_HIDE); break; } break; } case WM_CLOSE: PostQuitMessage(0); break; } return 0; } LRESULT CALLBACK GameMainDialogPrompt(HWND Dialogwindow, UINT Message, WPARAM wParam, LPARAM lParam){ switch(Message){ case WM_PAINT:{ PAINTSTRUCT ps; RECT rect; HDC hdc = GetDC(Dialogwindow);    hdc = BeginPaint(Dialogwindow, &ps); GetClientRect (Dialogwindow, &rect); FillRect(hdc, &rect, CreateSolidBrush(RGB(0, 0, 0)));    EndPaint(Dialogwindow, &ps);    break;  } case WM_COMMAND:{ switch(LOWORD(wParam)){ case IDC_HOST: if(!NET_Initialize()){ break; } if(server.CreateServer(7890, NET_UDP) != 0){ MessageBox(NULL, "Failed to create server.", "Error!", MB_OK); PostQuitMessage(0); return -1; } ShowWindow(d, SW_HIDE); break; case IDC_JOIN:{ JoinMenu(); } break; case IDC_EXIT: PostQuitMessage(0); break; default: break; } break; } return 0; } } I call the first dialog using the below code void EnterMenu(){ // joinDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_GETADDRESSINFO), g_hWnd, (DLGPROC)GameJoinDialogPrompt);// d = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_SELECTMENU), g_hWnd, (DLGPROC)GameMainDialogPrompt); } The dialog boxes are not DISABLED by default, and they are visible by default. Everything is set to be active on creation and no code deactivates the items on the dialog or the dialog itself.

    Read the article

  • problem in showing and hiding dialog boxes in MFC

    - by Rakesh
    Hello all, I am trying to create a wizard like structure using dialog boxes...So I replaced the code in CDialog1App as below CDialog1Dlg* dlg = new CDialog1Dlg; m_pMainWnd = dlg; dlg->Create(IDD_DIALOG1); dlg->ShowWindow(SW_SHOW); the above worked fine...its displying the dialog box.but I have added another dialog box... So in the first dialog box if the user clicks Next it has to hide the first dialog box and display the second dialog.. //CDialog1 class void CDialog1Dlg::OnBnClickedNext() { // TODO: Add your control notification handler code here CDialog2* dialog2 = new CDialog2(); dialog2->Create(IDD_DIALOG2); dialog2->ShowWindow(SW_SHOW); this->ShowWindow(SW_HIDE); } in the above code am creating an object for the Dialog2 class and trying to show that.... Now the problem is,when I click next its hiding both the windows..What can I do..I tried several types but its still its not workin..Please dont suggest me to do with PropertySheet..It will work with that, i know ...but I want this using Dialog Box for some reason

    Read the article

  • Failing to send key presses to a running process in C#

    - by Waffles
    I'm using the following code to put the focus on a window (in this case, a notepad window), and sending some key presses to it everytime button 2 is clicked. However, when I press button 2, nothing happens. Can anyone tell my why my sendkeys command is failing? public partial class Form1 : Form { [DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); private Process s; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.s = new Process(); s.StartInfo.FileName = "notepad"; s.Start(); s.WaitForInputIdle(); } private void button2_Click(object sender, EventArgs e) { ShowWindow(s.MainWindowHandle, 1); SendKeys.SendWait("Hello"); } }

    Read the article

  • Calling gwt static method from parent of iframe

    - by Richard Wallis
    I'd like to know how to call a GWT static method from the parent of the iframe in which the gwt module is loaded. As a simple example suppose I have the following gwt class: public class Simple { public static void showWindow() { Window.alert("Hello from the iframe"); } } I create an html host page called "iFrameHost.html" that can run the function above. Then in an unrelated GWT module on a different page I call: Frame iFrame = new Frame("iFrameHost.html"); RootPanel.get().add(iFrame); How do I now call the showWindow() method from the parent page?

    Read the article

  • DTPicker: how to open up an control expanded (by default)?

    - by Olli
    Hi all, in my windows form (Visual C++ 6.0) I'm using an Active x control called "CDTPicker" (CDTPicker : public CWnd). My control is opened up by the click event of another button. like this (works fine): void CProducerDlg::OnSelect() { ... m_wndDatePicker.SetValue(varVariant); // hide date combo box if first entry has been chosen m_wndDate.ShowWindow(SW_HIDE); // show date picker if first entry is chosen m_wndDatePicker.ShowWindow(SW_SHOW); // open up calendar view [tbd] ... } What I need is the calendar view to open up expanded (showing the complete month). I don't find any method to do this... Who can help me? Thanks in advance Olli

    Read the article

  • Why I cannot add a JPanel to JFrame?

    - by Roman
    Here is the code: import javax.swing.SwingUtilities; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import java.awt.event.*; import java.awt.*; public class GameWindow { private String[] players; private JFrame frame; // Constructor. public GameWindow(String[] players) { this.players = players; } // Start the window in the EDT. public void start() { SwingUtilities.invokeLater(new Runnable() { public void run() { showWindow(); controller.start(); } }); } // Defines the general properties of and starts the window. public void showWindow() { frame = new JFrame("Game"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(600,400); frame.setVisible(true); } // The thread controlling changes of panels in the main window. private Thread controller = new Thread() { public void run() { frame.add(generatePartnerSelectionPanel()); frame.invalidate(); frame.validate(); } }; // Generate the panel for the selection of a partner. private JPanel generatePartnerSelectionPanel() { JPanel panel = new JPanel(); panel.add(new JLabel("Pleas select a partner:")); return panel; } } I should see "Pleas select the partner" and I don't. Why? I suppose that it's because I do not see frame from the run method of the Thread.

    Read the article

  • Show RGB888 content

    - by Abhi
    Hi all! I have to show RGB888 content using the ShowRGBContent function. The below function is a ShowRGBContent function for yv12-rgb565 & UYVY-RGB565 static void ShowRGBContent(UINT8 * pImageBuf, INT32 width, INT32 height) { LogEntry(L"%d : In %s Function \r\n",++abhineet,WFUNCTION); UINT16 * temp; BYTE rValue, gValue, bValue; // this is to refresh the background desktop ShowWindow(GetDesktopWindow(),SW_HIDE); ShowWindow(GetDesktopWindow(),SW_SHOW); for(int i=0; i<height; i++) { for (int j=0; j< width; j++) { temp = (UINT16 *) (pImageBuf+ i*width*PP_TEST_FRAME_BPP+j*PP_TEST_FRAME_BPP); bValue = (BYTE) ((*temp & RGB_COMPONET0_MASK) >> RGB_COMPONET0_OFFSET) << (8 -RGB_COMPONET0_WIDTH); gValue = (BYTE) ((*temp & RGB_COMPONET1_MASK) >> RGB_COMPONET1_OFFSET) << (8 -RGB_COMPONET1_WIDTH); rValue = (BYTE) ((*temp & RGB_COMPONET2_MASK) >> RGB_COMPONET2_OFFSET) << (8 -RGB_COMPONET2_WIDTH); SetPixel(g_hDisplay, SCREEN_OFFSET_X + j, SCREEN_OFFSET_Y+i, RGB(rValue, gValue, bValue)); } } Sleep(2000); //sleep here to review the result LogEntry(L"%d :Out %s Function \r\n",++abhineet,__WFUNCTION__); } I have to modify this for RGB888 Here in the above function: ************************ RGB_COMPONET0_WIDTH = 5 RGB_COMPONET1_WIDTH = 6 RGB_COMPONET2_WIDTH = 5 ************************ ************************ RGB_COMPONET0_MASK = 0x001F //31 in decimal RGB_COMPONET1_MASK = 0x07E0 //2016 in decimal RGB_COMPONET2_MASK = 0xF800 //63488 in decimal ************************ ************************ RGB_COMPONET0_OFFSET = 0 RGB_COMPONET1_OFFSET = 5 RGB_COMPONET2_OFFSET = 11 ************************ Also PP_TEST_FRAME_BPP = 2 for yv12 -> RGB565 & UYVY -> RGB565 Now my task is for RGB888. Please guide me what shall i do in this. Thanks in advance.

    Read the article

  • How to Change an MFC Modeless Dialog to be the child of a CView in an MDI application?

    - by Kieveli
    I have an MFC application that is a Doc/View/Frame implementation. One dialog is running as a modeless dialog which pops up on demand (from a menu option). I'm looking to add the modeless dialog to an MDI child view. Basically, I want to load the template from the resource file, and create it as a child of the CView in my new trio (doc/view/frame) that I am adding to the template lists for the MDI. I've tried a few things in my derived CMyView class: void CMyView::OnInitialUpdate() { m_ListDialog = new Dialogs::CListDialog( m_config, this ); m_ListDialog->Create( Dialogs::CListDialog::IDD, this ); m_ListDialog->ShowWindow( SW_SHOW ); } I've tried calling SetWindowPos, ModifyStyle (WS_CHILD, WS_VISIBLE, DS_CONTROL). I've tried modifying the resource file to set the child and control manually. Everytime it calls Create, the ListDialog's m_hWnd is left as 0. This tells me it's not getting created properly. Any call to SetWindowPos() or ShowWindow() fails because the m_hWnd is 0 (debug assertion fails). What do I need to do to get a modeless dialog to be constructed, created, and appear as a child to CMyView in my MDI application?

    Read the article

  • Games to Vista Game explorer with Inno Setup

    - by Kraemer
    Ok, i'm trying to force my inno setup installer to add a shortcut of my game to Vista Games Explorer. Theoretically this should do the trick: [Files] Source: "GameuxInstallHelper.dll"; DestDir: "{app}"; Flags: ignoreversion overwritereadonly; [Registry] Root: HKLM; Subkey: SOFTWARE\dir\dir; Flags: uninsdeletekeyifempty Root: HKLM; Subkey: SOFTWARE\dir\dir; ValueName: Path; ValueType: String; ValueData: {app}; Flags: uninsdeletekey Root: HKLM; Subkey: SOFTWARE\dir\dir; ValueName: AppFile; ValueType: String; ValueData:{app}\executable.exe ; Flags: uninsdeletekey [CustomMessages] en.Local=en en.removemsg=Do you wish to remove game saves and settings? en.taskentry=Play [Code] const PlayTask = 0; AllUsers = 2; Current = 3; type TGUID = record Data1: Cardinal; Data2, Data3: Word; Data4: array [0..7] of char; end; var GUID: TGUID; function GetDC(HWND: DWord): DWord; external '[email protected] stdcall'; function GetDeviceCaps(DC: DWord; Index: Integer): Integer; external '[email protected] stdcall'; function ReleaseDC(HWND: DWord;DC: DWord): Integer; external '[email protected] stdcall'; function ShowWindow(hWnd: DWord; nCmdShow: Integer): boolean; external '[email protected] stdcall'; function SetWindowLong(hWnd: DWord; nIndex: Integer; dwNewLong: Longint):Longint; external '[email protected] stdcall'; function GenerateGUID(var GUID: TGUID): Cardinal; external 'GenerateGUID@files:GameuxInstallHelper.dll stdcall setuponly'; function AddToGameExplorer(Binary: String; Path: String; InstallType: Integer; var GUID: TGUID): Cardinal; external 'AddToGameExplorerW@files:GameuxInstallHelper.dll stdcall setuponly'; function CreateTask(InstallType: Integer; var GUID: TGUID; TaskType: Integer; TaskNumber: Integer; TaskName: String; Binary: String; Parameters: String): Cardinal; external 'CreateTaskW@files:GameuxInstallHelper.dll stdcall setuponly'; function RetrieveGUIDForApplication(Binary: String; var GUID: TGUID): Cardinal; external 'RetrieveGUIDForApplicationW@{app}\GameuxInstallHelper.dll stdcall uninstallonly'; function RemoveFromGameExplorer(var GUID: TGUID): Cardinal; external 'RemoveFromGameExplorer@{app}\GameuxInstallHelper.dll stdcall uninstallonly'; function RemoveTasks(var GUID: TGUID): Cardinal; external 'RemoveTasks@{app}\GameuxInstallHelper.dll stdcall uninstallonly'; function InitializeSetup(): Boolean; var appath: string; ResultCode: Integer; begin if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\dir\dir') then begin RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\dir\dir', 'Path', appath) Exec((appath +'\unins000.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) end else begin Result := TRUE end; end; procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); begin if CurUninstallStep = usUninstall then begin if GetWindowsVersion shr 24 > 5 then begin RetrieveGUIDForApplication(ExpandConstant('{app}\AWL_Release.dll'), GUID); RemoveFromGameExplorer(GUID); RemoveTasks(GUID); UnloadDll(ExpandConstant('{app}\GameuxInstallHelper.dll')); end; end; if CurUninstallStep = usPostUninstall then begin if MsgBox(ExpandConstant('{cm:removemsg}'), mbConfirmation, MB_YESNO)=IDYES then begin DelTree(ExpandConstant('{app}'), True, True, True); end; end; end; procedure CurStepChanged(CurStep: TSetupStep); begin if GetWindowsVersion shr 24 > 5 then begin if CurStep = ssInstall then GenerateGUID(GUID); if CurStep = ssPostInstall then begin AddToGameExplorer(ExpandConstant('{app}\AWL_Release.dll'), ExpandConstant('{app}'), Current, GUID); CreateTask(3, GUID, PlayTask, 0, ExpandConstant('{cm:taskentry}'), ExpandConstant('{app}\executable.exe'), ''); CreateTask(3, GUID, 1, 0, 'Game Website', 'http://www.gamewebsite.com/', ''); end; end; end; The installer works just fine, but it doesn't place a shortcut of my game to Games explorer. Since i believe that the problem is on the binary file i guess for that part i should ask for some help. So, can anyone please give me a hand here?

    Read the article

  • how to start a smartdevice application minimized in c#

    - by x86shadow
    I made a smart device application in c# and I want to run it at startup (I know how to do that) but the problem is that I can't make my application to run minimized (hidden) on the first time. I've tried this.Hide() and this.Visible = false and also used ShowWindow API with SW_HIDE(6) but non of them worked. It seems it's impossible to use these methods on Form_Load() or in InitializeComponent() to start the application minimized or hidden. anyone can help me with this ?

    Read the article

  • How to fix this window.open memory leak?

    - by DotnetShadow
    Hi there, I was recently looking at this memory leak tool sIEve: http://home.orange.nl/jsrosman/ So I decided to test out the tool by creating a main page that will open up a popup window. I started by creating 3 pages: index.html, page1.html and page2.html, the index.html page will open a child window (popup) linking to page1.html. Page1 will have a anchor tag that links to page2.html, while page2 will have a link back to page1.html PROBLEM So in the tool I entered the index.html page, popup window opened to page1.html, I then clicked the page2 link, no leaks detected yet. While I'm on page2 I click the link back to page1, and that's where the tool claims there is a link. The leak seems to be happening on the index.html page and I have no idea as to why it would be doing that. Even more concerning is that I can see elements that the tool detects that aren't even on my page. Does anyone have any experience with this tool or know if this really is a memory leak? Any samples of showing how to achieve what I'm doing without memory leaks? INDEX.HTML <script type="text/javascript"> MYLEAK = function() { var childWindow = null; function showWindow() { childWindow = window.open("page1.html", "myWindow"); return false; } return { init: function() { $("#window-link").bind("click", showWindow); } } }(); </script> </head> <body> <a id="window-link" href="#" on>Open Window</a> <script type="text/javascript"> $(document).ready(function() { MYLEAK.init(); }); </script> </body> </html> PAGE1.HTML <html> <body> <h1>Page 1</h1> <a href="page2.html">Page2</a> </body> </html> PAGE2.HTML <html> <body> <h1>Page 2</h1> <a href="page1.html">Page1</a> </body> </html> Appreciate your efforts.

    Read the article

  • How to hide/show a Process using c#?

    - by aF
    Hello, While executing my program, I want to hide/minimize Microsoft Speech Recognition Application: and at the end I want to show/maximize using c#! This process is not started by me so I can't give control the process startInfo. I've tried to use user32.dll methods such as: ShowWindow AnimatedWindows AnimatedWindows With all of them I have the same problem. I can hide the windows (althought I have to call one of the methods two times with SW_HIDE option), but when I call the method with a SW_SHOW flag, it simply doesn't shows.. How can I maximize/show after hiding the process? Thanks in advance! Here is some pieces of the code, now implemented to use SetWindowPlacement: { [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl); [DllImport("user32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WINDOWPLACEMENT lpwndpl); [DllImport("user32.dll")] public static extern Boolean ShowWindowAsync(IntPtr hWnd, Int32 nCmdShow); [DllImport("user32.dll")] public static extern Boolean SetForegroundWindow(IntPtr hWnd); [DllImport("user32.dll")] public static extern Boolean ShowWindow(IntPtr hWnd, Int32 nCmdShow); [DllImport("user32.dll")] public static extern Boolean AnimateWindow(IntPtr hWnd, uint dwTime, uint dwFlags); [DllImport("dwmapi.dll")] public static extern int DwmSetWindowAttribute(IntPtr hwnd, uint dwAttribute, IntPtr pvAttribute, IntPtr lol); //Definitions For Different Window Placement Constants const UInt32 SW_HIDE = 0; const UInt32 SW_SHOWNORMAL = 1; const UInt32 SW_NORMAL = 1; const UInt32 SW_SHOWMINIMIZED = 2; const UInt32 SW_SHOWMAXIMIZED = 3; const UInt32 SW_MAXIMIZE = 3; const UInt32 SW_SHOWNOACTIVATE = 4; const UInt32 SW_SHOW = 5; const UInt32 SW_MINIMIZE = 6; const UInt32 SW_SHOWMINNOACTIVE = 7; const UInt32 SW_SHOWNA = 8; const UInt32 SW_RESTORE = 9; public sealed class AnimateWindowFlags { public const int AW_HOR_POSITIVE = 0x00000001; public const int AW_HOR_NEGATIVE = 0x00000002; public const int AW_VER_POSITIVE = 0x00000004; public const int AW_VER_NEGATIVE = 0x00000008; public const int AW_CENTER = 0x00000010; public const int AW_HIDE = 0x00010000; public const int AW_ACTIVATE = 0x00020000; public const int AW_SLIDE = 0x00040000; public const int AW_BLEND = 0x00080000; } public struct WINDOWPLACEMENT { public int length; public int flags; public int showCmd; public System.Drawing.Point ptMinPosition; public System.Drawing.Point ptMaxPosition; public System.Drawing.Rectangle rcNormalPosition; } //this works param = new WINDOWPLACEMENT(); param.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT)); param.showCmd = (int)SW_HIDE; lol = SetWindowPlacement(theprocess.MainWindowHandle, ref param); // this doesn't work WINDOWPLACEMENT param = new WINDOWPLACEMENT(); param.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT)); param.showCmd = SW_SHOW; lol = GetWindowPlacement(theprocess.MainWindowHandle, ref param);

    Read the article

  • Show CMFCRibbonStatusBar

    - by praetorian20
    Hi, I'm creating a simple SDI app using the new VS2008 service pack. I added ribbon support but all I want on the ribbon are the Open & Close buttons. I commented out all the code that creates the other default buttons and categories but doing this also gets rid of the status bar (CMFCRibbonStatusBar). I can't find what member function is called when I click the checkbox that displays the statusbar in the default generated code. I've tried the following but it doesn't work: m_wndStatusBar.ShowWindow( SW_SHOWNORMAL ); How do I have the status bar showing without having to have the 'Home' category and 'View' panel (with the 'Show status bar' checkbox) being generated? Thanks, Ashish.

    Read the article

  • mfc tab control switch tabs

    - by MRM
    I created a simple tab control that has 2 tabs (each tab is a different dialog). The thing is that i don't have any idea how to switch between tabs (when the user presses Titlu Tab1 to show the dialog i made for the first tab, and when it presses Titlu Tab2 to show my other dialog). I added a handler for changing items, but i don't know how should i acces some kind of index or child for tabs. Tab1.h and Tab2.h are headers for dialogs that show only static texts with the name of the each tab. There may be an obvious answer to my question, but i am a real newbie in c++ and MFC. This is my header: // CTabControlDlg.h : header file // #pragma once #include "afxcmn.h" #include "Tab1.h" #include "Tab2.h" // CCTabControlDlg dialog class CCTabControlDlg : public CDialog { // Construction public: CCTabControlDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data enum { IDD = IDD_CTABCONTROL_DIALOG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: HICON m_hIcon; // Generated message map functions virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP() public: CTabCtrl m_tabcontrol1; CTab1 m_tab1; CTab2 m_tab2; afx_msg void OnTcnSelchangeTabcontrol(NMHDR *pNMHDR, LRESULT *pResult); }; And this is the .cpp: // CTabControlDlg.cpp : implementation file // #include "stdafx.h" #include "CTabControl.h" #include "CTabControlDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP() // CCTabControlDlg dialog CCTabControlDlg::CCTabControlDlg(CWnd* pParent /*=NULL*/) : CDialog(CCTabControlDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CCTabControlDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_TABCONTROL, m_tabcontrol1); } BEGIN_MESSAGE_MAP(CCTabControlDlg, CDialog) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_NOTIFY(TCN_SELCHANGE, IDC_TABCONTROL, &CCTabControlDlg::OnTcnSelchangeTabcontrol) END_MESSAGE_MAP() // CCTabControlDlg message handlers BOOL CCTabControlDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here CTabCtrl* pTabCtrl = (CTabCtrl*)GetDlgItem(IDC_TABCONTROL); m_tab1.Create(IDD_TAB1, pTabCtrl); TCITEM item1; item1.mask = TCIF_TEXT | TCIF_PARAM; item1.lParam = (LPARAM)& m_tab1; item1.pszText = _T("Titlu Tab1"); pTabCtrl->InsertItem(0, &item1); //Pozitionarea dialogului CRect rcItem; pTabCtrl->GetItemRect(0, &rcItem); m_tab1.SetWindowPos(NULL, rcItem.left, rcItem.bottom + 1, 0, 0, SWP_NOSIZE | SWP_NOZORDER ); m_tab1.ShowWindow(SW_SHOW); // al doilea tab m_tab2.Create(IDD_TAB2, pTabCtrl); TCITEM item2; item2.mask = TCIF_TEXT | TCIF_PARAM; item2.lParam = (LPARAM)& m_tab1; item2.pszText = _T("Titlu Tab2"); pTabCtrl->InsertItem(0, &item2); //Pozitionarea dialogului //CRect rcItem; pTabCtrl->GetItemRect(0, &rcItem); m_tab2.SetWindowPos(NULL, rcItem.left, rcItem.bottom + 1, 0, 0, SWP_NOSIZE | SWP_NOZORDER ); m_tab2.ShowWindow(SW_SHOW); return TRUE; // return TRUE unless you set the focus to a control } void CCTabControlDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CCTabControlDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR CCTabControlDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CCTabControlDlg::OnTcnSelchangeTabcontrol(NMHDR *pNMHDR, LRESULT *pResult) { // TODO: Add your control notification handler code here *pResult = 0; }

    Read the article

  • How to correctly pop a modeless dialog from console using MFC

    - by Vertilka
    I need to create a console application that has a main() function and pop a modeless dialog, so the console can still work in parallel to the modeless dialog (do other work, like communicating with the modeless dialog). Whatever i tried, i could only pop a modal dialog. (where the console is in hold till the modal dialog close itself). When switching to modeless dialog using Create() and ShowWindow() the dialog is displayed without its controls and it freeze / block (you can see the hourglass cursor). 1) i tried to pop the modeless dialog from the main() function 2) i tried to pop the modeless dialog from the InitInstance() of a CWinApp derived class In all cases the modeless dialog freeze / block. I believe this is a one line solution. TNX,Vertilka

    Read the article

  • .NET 2.0 vs .NET 4.0 loading error

    - by David Rutten
    My class library is compiled against .NET 2.0 and works just fine whenever I try to load it as a plugin under the 2.0 runtime. If however the master application is running the .NET 4.0 runtime, I get an exception as soon as the resources need to be accessed: Exception occurred during processing of command: Grasshopper Plug-in = Grasshopper Could not find file 'Grasshopper.resources'. Stack trace: at UnhandledExceptionLogger.UnhandledThreadException(Object sender, ThreadExceptionEventArgs args) at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t) at System.Windows.Forms.Control.WndProcException(Exception e) at System.Windows.Forms.ControlNativeWindow.OnThreadException(Exception e) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow(Handle Ref hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.Show(IWin32Window owner) .... What's going on and how do I make my project load on all .NET Runtimes?

    Read the article

  • NSWindowController and isWindowLoaded

    - by Jim
    Hi, I have an NSWindowController and I initialize it like this; + (MyWindowController *) sharedController { static MyWindowController *singleton = nil; if (!singleton) singleton = [[self alloc] initWithWindowNibName: @"myWindow"]; return singleton; } and I show windows like this; [[MyWindowController sharedController] showWindow: nil]; Now the problem is that I need information from some controls on that window. But I do not want to load the window if it's not yet loaded because then I can just go with the defaults. Should I use @property to access the singleton? or what is recommended here? (If @property, then please give me the readonly, nonatomic attributes too.)

    Read the article

  • Does a modeless dialog processes WM_DESTROY Message?

    - by Dave17
    I'm trying to create a modeless dialog as the main window of a program but it doesn't seem to respond WM_DESTROY or WM_NCDESTROY Message. HWND hwnd=CreateDialogParamA(hInst,MAKEINTRESOURCE(IDD_DIALOG1),0,DialogProc,LPARAM(this)); if (!hwnd) { MessageBox(0, "Failed to create wnd", 0, 0); return NULL; } ShowWindow(hwnd,nCmd); UpdateWindow(hwnd); while (GetMessage (&msg, NULL, 0, 0) > 0) { if (!IsWindow(hwnd) || !IsDialogMessage(hwnd,&msg)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } } Modeless Style format from Resource file STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU

    Read the article

  • Is there a reliable way to activate / set focus to a window using C#?

    - by gtaborga
    Hey everyone, I'm trying to find a reliable way to activate / set focus a window using C#. Currently I'm attempting to achieve this using the following Windows API calls: SetActiveWindow(handle); SwitchToThisWindow(handle, true); Previously I also had ShowWindow(handle, SW_SHOWMAXIMIZED); executing before the other 2, but removed it because it was causing strange behavior. The problem I'm having with my current implementation is that occasionally the focus will not be set correctly. The window will become visible but the top part of it will still appear grayed out as if it wasn't in focus. Is there a way to reliably do this which works 100% of the time, or is the inconsistent behavior a side-effect I can't escape? Please let me know if you have any suggestions or implementations that always work. Thank you for your time.

    Read the article

  • Why does DestroyWindow close my application?

    - by user146780
    I'v created a window after creating my main one but calling DestroyWindow on its handle closes the entire application, how can I simply get rid of it? it looks like this: BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; HWND fakehandle; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW | WS_EX_LAYERED, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); fakehandle = CreateWindow(szWindowClass, "FAKE WINDOW", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd || !fakehandle) { return FALSE; } //some code DestroyWindow(fakehandle); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } how can I destroy this window without destroying my main one? I'm creating a dummy window to check for multisampling in OpenGL. Thanks

    Read the article

1 2 3  | Next Page >