|
just give both buttons the same ID in resources or resource.h and I hope it does the work for you.
cheers
Himanshu
|
|
|
|
|
I spent about an hour solving a really similar problem today. I'm using a CPropertySheet derived class, that sits on a CFormView derived class, and the CPropertyPage classes each were supposed to have the Enter key hooked up to the default button on the CFormView derived class. I'm not on my dev machine right now, so I can't give code or exact answers, but if my situation sounds similar to yours, I can send you some code/answers tomorrow.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
You can have your CTab::OnButton() -handler send a Message (WM_APP +const or registered message) to your main window. A handler there would then just call the CWhateverDlg::OnButton1() function.
Alternatively, you could forge a WM_COMMAND for that Button and send it to your dialog, but I don't think that this is better.
Maybe you have no access to your dialog-class from the Tab-control-class: Then you could divert via a Handler in the MainFrame, which simply routes the same message to his child-dialog.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
thanks all, i will be trying this stuff out as soon as i get home and ill give a conclusion or further assistance post
todo....
:: insert inpirational text here ::
|
|
|
|
|
dear all,
your urgent attention is required!!!!!!!!!!!!!
I'm in a strange problem with absolutely no clues!
i'm using LogonUser(..) function with flag LOGON32_LOGON_INTERACTIVE to obtain the Administrator user token. The function returns ERROR_SUCCESS(0).
now i use the administrator token returned by the above function in CreateProcessAsUser(..).
the problem is that I get an error message ACCESS_DENIED (error code 5).
I even tried ImpersonateLoggedOnUser(..) (returns ERROR_SUCCESSS ) after LogonUser and then CreateProcess() or CreateProcessAsUser but still no respite from Error 5 (ACCESS_DENIED )
Is there anything else regarding security which needs to be done before calling CreateProcessAsUser(..) and after impersonating a user.
the code for is as follows:_
/*Calling LogonUser*/
BOOL bRes = LogonUser (sUserName.GetBuffer(sUserName.GetLength()) ,
sDomain.GetBuffer(sDomain.GetLength()) ,
sPassword.GetBuffer(sPassword.GetLength()) ,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
&(hnd));
/*Now Impersonating the user */
ImpersonateLoggedOnUser(hnd); /*Returns ERROR_SUCCESS */
/*now calling CreateProcessAsUser or CreateProcess depending on success of ImpersonateLoggedOnUser */
BOOL bRes = CreateProcessAsUser(hUserToken,
NULL ,
clp,
NULL, NULL,
TRUE,
NORMAL_PRIORITY_CLASS,
NULL, NULL,
&start,
&process);
/* Returns ACCESS_DENIED */
is there Anything to do with the security descriptors or Am I missing something else crucial?
PLZ. Respond,
regards,
rishabhs
|
|
|
|
|
i'm surprized!!!!!!!!!!
this is the third time i've posted my problem,
only to find absolutely no clue or some piece of help from any of the techies around.
what's the matter?
is the problem impossible to rectify or is there something wrong with my face which prevents you from responding.
waiting for evaluation...........................
rishabhs
|
|
|
|
|
:-Onothing like that dear..i am also surprised..but I can't help you because i have never worked on anything like that..so got no clue so as so what should be done..maybe you are at a point where you need to think from the scratch..and go on like that..just try to think it over and maybe you don't need any help..I hope you do it soon...well if you do ten please do tell me too...and what is it you are working on..
cheers
Himanshu
|
|
|
|
|
can't you debug it..just try and understand at what point what are the values int the variables and what is it you were expecting...when u will do a thorough debugging I hope you will come up with the solution of your question..try to see what are the user information and what is the exact reason why u r getting it like this..
cheers
Himanshu
|
|
|
|
|
i think u r the only one to ponder over my prob!
i'm sorry for the delay in replying,
u know the murphy's laws, that's the case for me!
i can't even debug my app in win Xp (i don't know why) i get an error in MSDEv.exe as soon as i try to debug!
all i want is to give admin rights to my application which will work in guest login with all the security restrictions!
but no luck!
i've checked the value in variables using error logging, thay are going the way as i want but still i get an error Acccess_denied while executing a process after impersonating administrator!
anyways thanx for ur concern!!!!!!
|
|
|
|
|
I am trying to create some controls during runtime. I resolved all my errors but I think it now has a memory leak. Not sure how to test that, but I don't delete array at the end. I have commented out once place I was trying to delete the array in the WM_CLOSE section. Can anyone help me be able to delete the array and get no errors? here is the code I am using to do this. It also requires a dialog box named IDD_DIALOG1 (generic name) and a push buton IDOK. (just add a dialog into the resource editor and it should work.
---BEGIN CODE---
#include <afx.h>
#include <windows.h>
#include "resource.h"
HWND HWND_DLG_MAIN;
HINSTANCE ghInstance;
//made global to attempt to reduce possible problems
CString szTmp;
HWND *StaticArr;
HWND *temp;
int cnt = 0;
int x = 10;
int y = 10;
int h = 75;
int w = 25;
int loopctr = 0;
BOOL MainWndProc(HWND, UINT, WPARAM, LPARAM);//Main window procedure
BOOL MainOnCommand(HWND, WORD, WORD, HWND);//WM_COMMAND procedure
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, int)
{
ghInstance = hInstance;
DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1),
NULL, (DLGPROC)MainWndProc, 0);//Create the main dialog box
return FALSE;
}
BOOL MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
HWND_DLG_MAIN = hWnd;
break;
case WM_COMMAND:
MainOnCommand(HWND_DLG_MAIN, LOWORD(wParam), HIWORD(wParam), (HWND)lParam);
break;
case WM_CLOSE:
for(loopctr = 0; loopctr < cnt; loopctr++)
DestroyWindow(StaticArr[loopctr]);
//delete [] StaticArr;
EndDialog(HWND_DLG_MAIN, 0);
DestroyWindow(hWnd);
break;
}
return FALSE;
}
BOOL MainOnCommand(HWND hWnd, WORD wCommand, WORD wNotify, HWND hControl)
{
switch(wCommand)
{
case IDOK:
if(cnt > 1)
{
temp = new HWND[cnt];
}
else
{
temp = new HWND[1];
}
temp = StaticArr;
if(cnt > 1)
{
delete [] StaticArr;
}
StaticArr = new HWND[++cnt];
delete [] temp;
szTmp.Format("Label-%d", cnt);
StaticArr[cnt-1] = CreateWindowEx(
NULL, // extended window style
"STATIC", // pointer to registered class name
szTmp, // pointer to window name
WS_CHILD | WS_VISIBLE | WS_BORDER,// window style
x, // horizontal position of window
y, // vertical position of window
h, // window width
w, // window height
HWND_DLG_MAIN, // handle to parent or owner window
NULL, // handle to menu, or child-window identifier
ghInstance, // handle to application instance
NULL // pointer to window-creation data
);
y+=25;//move the next label down some
break;
}
return FALSE;
}
---END CODE---
Thanks for any help you can give me on this. I am not sure where, and now even if, I need to delete the Array at.
Just to note, it is StaticArr that I am trying to figure out where to delete.
EDIT - When making over 443controls, it errors out as well. Not so concerned about this, because if it ever needs that many controls, I'll shoot my database.
Quinn
The wisest of the wise may err. - Aeschylus
|
|
|
|
|
I guess thats the only thing you are doing is deleting it at a wrong time, what i suggest it you initialize the array in constructor of the application and delete it in destructor. or if you wanna go like this then too i can't understand this bit..
DestroyWindow(StaticArr[loopctr]);
//delete [] StaticArr;
EndDialog(HWND_DLG_MAIN, 0);
DestroyWindow(hWnd);
why don't you just delete array and enddialog() then destroywindow.
thats all i can suggest at this time..
cheers
Himanshu
|
|
|
|
|
I found the answer.
I was setting the pointers equal and when I deleted I freed the chunk of memory both were pointing to, and when I created new it created a new chunk. Took a few to get out of sync.
I just had to add in a for loop and it works all better now.
Thanks for anyway working to try and get me an answer.
I changed the IF statement structure section to this
---BEG CODE---
if(cnt < 1)
{
StaticArr = new HWND[++cnt];
}
else if(cnt > 0)
{
temp = new HWND[cnt];
for(loopctr=0; loopctr < cnt; loopctr++)
{
temp[loopctr] = StaticArr[loopctr];
}
delete [] StaticArr;
StaticArr = new HWND[++cnt];
for(loopctr=0; loopctr < cnt; loopctr++)
{
StaticArr[loopctr] = temp[loopctr];
}
delete [] temp;
}
---END CODE---
The wisest of the wise may err. - Aeschylus
|
|
|
|
|
hello @all,
i have a mfc-program and two CStrings.
i would like to connect these, but everyone in its own line, e.g. they should be separated with a Return.
CString one="123";
CString two="456";
CString combination="123
456";
how can i get the CString 'combination'????
thanks
sunny
|
|
|
|
|
"123\n456" will place a return between the new strings when the string is output.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
hello,u can do it as following:
combination=one+two;
|
|
|
|
|
Hello,
u can do it as this:
combination=one+0X0A+0X0D+two;
good luck!
|
|
|
|
|
In my program (VISUAL C++ MFC) I have to open a window to visualize a video captured by a webcam (in real time). So how can I visualize the streaming video when the webcam start capturing? Do you know if there is a web site with some sample source code?? Thank U very much!! And sorry for my question but I've not long experience with C++...
|
|
|
|
|
I think you should use DirectShow for this work.
There are some samples and tutorials about DirectShow on the MSDN.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_c/directx_cpp/htm/directshow.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_c/directx_cpp/htm/directshowsamples.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_c/directx_cpp/htm/directshowtutorials.asp
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hi,
I want to turn the pc off from a c++ program
Im using MFC and have a timer that can be used or after an event i want to call a function that would turn your pc off
any ideas?
thanks guys
Li Mu Bai
|
|
|
|
|
Hi
Try ExitWindowsEx(EWX_POWEROFF, 0);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
Hope someone can help me out here please. I'm trying to create a status bar in my app so I added the function:
<br />
HWND DoCreateStatusBar(HWND hwndParent, int nStatusID, <br />
HINSTANCE hinst, int nParts) <br />
{ <br />
HWND hwndStatus; <br />
RECT rcClient; <br />
HLOCAL hloc; <br />
LPINT lpParts; <br />
int i, nWidth; <br />
<br />
InitCommonControls(); <br />
<br />
hwndStatus = CreateWindowEx( <br />
0,
STATUSCLASSNAME,
(LPCTSTR) NULL,
SBARS_SIZEGRIP |
WS_CHILD,
0, 0, 0, 0,
hwndParent,
(HMENU) nStatusID,
hinst,
NULL);
<br />
GetClientRect(hwndParent, &rcClient); <br />
<br />
hloc = LocalAlloc(LHND, sizeof(int) * nParts); <br />
lpParts = (LPINT)LocalLock(hloc); <br />
<br />
nWidth = rcClient.right / nParts; <br />
for (i = 0; i < nParts; i++) { <br />
lpParts[i] = nWidth; <br />
nWidth += nWidth; <br />
} <br />
<br />
SendMessage(hwndStatus, SB_SETPARTS, (WPARAM) nParts, <br />
(LPARAM) lpParts); <br />
<br />
LocalUnlock(hloc); <br />
LocalFree(hloc); <br />
return hwndStatus; <br />
} <br />
Which I got from MSDN. Then in my wndproc case: WM_CREATE I put in:
<br />
statusbar = DoCreateStatusBar(hwnd, ID_STATUSBAR, hInst, 4);<br />
Everything compiles fine but unfortunately I don't get a status bar, is there some message I have to send it to make it display itself?
Thanks in advance,
Paddy.
|
|
|
|
|
Did you forget to call InitCommonControls() or InitCommonControlsEx(). If so then that is the reason.
|
|
|
|
|
Thanks for the help, I was calling InitCommonControls() but I forgot to include the WS_VISIBLE flag when I was creating the status bar!
|
|
|
|
|
I am attempting to develop an ActiveX control subclassed from the MFC Listbox.
Following the MSDN tutorial, I set everything up through the Control Wizard, including setting LISTBOX as the subclassed windows control. The problem is, the tutorials (I have read several) all say "If you want your subclassed control to keep the same appearance as the corresponding Windows control, the OnDraw member function for the control should contain only a call to the DoSuperclassPaint member function, as in the following example:
void CSampleCtrl::OnDraw( CDC* pdc, const CRect& rcBounds,
const CRect& rcInvalid )
{
DoSuperclassPaint( pdc, rcBounds );
}
"
Which is what the Control Wizard automatically does and which is how I left it. I was thinking that if I just leave it like so, when I add it to a new project, it will draw me a standard-looking listbox. Instead, I get a plain white box. I also tried calling AddString in my project and was informed by the compiler that the method does not exist.
So far I see no evidence of my ActiveX control being subclassed form LISTBOX (I have the following as well provided by class wizard:
BOOL CSampleCtrl::PreCreateWindow( CREATESTRUCT& cs )
{
cs.lpszClass = _T("BUTTON");
return COleControl::PreCreateWindow(cs);
}
BOOL CSampleCtrl::IsSubclassedControl( )
{
return TRUE;
}
)
Why am I just getting a white box?? Are there some message handlers I need to address first?? As for the AddString not working, I'm still a little rusty on subclassing... do I have to add methods for all listbox methods I want to use in my control and just call CListbox::Addstring(blah, blah, blah) in order to use the Listbox Functionality???
I have read a lot of articles and tutorials on subclassing and activex controls and mfc controls and there seems to be something that I don't know that is overlooked or assumed to be obvious. Any ideas??
Tym!
|
|
|
|
|
You might want to check your listbox styles. It should "Have Strings" and not be "Owner Draw".
You can pick your friends, and you can pick your nose, but you can't pick your friend's nose.
|
|
|
|
|