|
In my app I want to use the dialog based app toghethere with MDI. It is simply to much work to do to copy/paste all the cpp-s and header files from a project to another. I just want to build them together considering that they are different modules from a program and I want to pass parameters and functions between them.
Isn't there another posibility than the other 2 described by you? In the first case I think I complicate far to much for what i want to do. What about using dll-s and lib files. Cand you tell me something about them ?
|
|
|
|
|
Is there any way to find out whether desired service is running on the remote port?? i am just scanning for well known ports
|
|
|
|
|
How do i write an application so that it does not run when opened by any user other than administrator? my application is a dialog based application. so i do not want to initialise my dialog when i m not administrator. i just want to show a message box saying the application runs only as administrator. how do i check administrator rights through a VC++ program?
suggestions needed.
|
|
|
|
|
This is a reply to a similar question that I copied from a forum:
[Reply]
This piece of code should be what you are looking for. Also, the article Searching for a SID in an Access Tokenin the Widows Base Services: Platform SDK on the MSDN Library Visual Studio 6.0 will help.
HANDLE hToken = NULL;
PTOKEN_GROUPS pGroupInfo = NULL;
DWORD dwSize = 0;
DWORD loop = 0;
PSID pSID = NULL;
BOOL bSidCheck = FALSE;
SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_NT_AUTHORITY;
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken);
GetTokenInformation(hToken, TokenGroups, NULL, 0, &dwSize);
pGroupInfo = (PTOKEN_GROUPS)new BYTE[dwSize];
GetTokenInformation(hToken, TokenGroups, pGroupInfo, dwSize, &dwSize);
/**** well-know SID *****/
//DOMAIN_ALIAS_RID_ADMINS
//DOMAIN_ALIAS_RID_USERS
//DOMAIN_ALIAS_RID_GUESTS
//DOMAIN_ALIAS_RID_POWER_USERS
//DOMAIN_ALIAS_RID_ACCOUNT_OPS
//DOMAIN_ALIAS_RID_SYSTEM_OPS
//DOMAIN_ALIAS_RID_PRINT_OPS
//DOMAIN_ALIAS_RID_BACKUP_OPS
//DOMAIN_ALIAS_RID_REPLICATOR
// Creating a SID for the BUILTIN\Administrators group. Could use others
AllocateAndInitializeSid(&SIDAuth, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,0, 0,0,0,0,0, &pSID);
for(loop = 0; loop < pGroupInfo->GroupCount; loop++)
{
// Check All Groups to see if a match to the ADMIN SID that was created if(EqualSid(pGroupInfo->Groups[loop].Sid, pSID))
{
bSidCheck = TRUE;
break;
}
}
delete [] pGroupInfo;
CloseHandle(hToken);
if (pSID)
{
FreeSid(pSID);
}
if (pGroupInfo)
{
GlobalFree(pGroupInfo);
}
if(bSidCheck)
{
//came back with a Match
}
else
{
//No Match
}
[/Reply]
If you vote me down, my score will only get lower
|
|
|
|
|
In A dialog based application where should i put this code segment. in initDialog()?
|
|
|
|
|
I try to get a notification when the user change the current selection in a CListCtrl.
It is possible to get one whith the NM_CLICK event (when the user clicks on it), but I don't know how to get the new selection when the user changes the current selection width the arrows ...
is there any message like TVN_SELCHANGED (for CTreeCtrl) ?
Thx.
--
Gizmo
|
|
|
|
|
Simply provide a handler for the LVN_ITEMCHANGED notification. The iItem member of the NM_LISTVIEW structure will be the number of the selected item. Or, you can just call GetNextItem(-1, LVNI_SELECTED) .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
ok, it works, thx
--
Gizmo
|
|
|
|
|
HI,
As i Windows Media Player ,, the Title bar Portion of Meia plauer hides when we select the option of Auto Hide menu bar ....
How can i do it with my dialog ,, assume it is a simple dailog with a Menu bar , etc and few buttons.
waitng for sample help
thanks
|
|
|
|
|
You can hide controls via the
ShowWindow(SW_HIDE)<br />
ShowWindow(SW_SHOW)
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I want to Hide Title bar and Some Portion of Dialog
as follows
______________________________________
| Title Bar + Menus |
|_____________________________________|
| | |
| | |
| | |
| | |
| | |
| | Button1 |
| My Picture Window | |
| to play video | Button 2 |
| | |
| | |
|_____________________________________|
1... I want to hide Title Bar and Menus
Plus if possible
the Portion where the Button , i want to hide this also
thanx
|
|
|
|
|
I did once a trick by setting a groupbox around the controls.
This groupbox' rectangle is exactly the rectangle to hide. You can then redraw your video window.
how to hide your menu I don't know.
here's some sample code I've used.
CRect filterrect;
CRect flexlistrect;
CRect hsbtnrect;
CWnd* pWnd;<br />
pWnd = (CWnd*)GetDlgItem(IDC_STATIC3);<br />
pWnd->GetClientRect(filterrect);<br />
m_lstActivations.GetClientRect(flexlistrect);<br />
m_btnhideshow.GetClientRect(hsbtnrect);<br />
<br />
topoflisthidden = hsbtnrect.bottom + 15;<br />
topoflistshown = filterrect.bottom + hsbtnrect.bottom + 15;<br />
bottomoflisthidden = flexlistrect.bottom + filterrect.bottom + hsbtnrect.bottom - 5;<br />
bottomoflistshown = bottomoflisthidden - (filterrect.bottom);<br />
widthoflist = filterrect.right;
<br />
if(showed == false){<br />
sortcol = 2;
CWnd *pWnd;<br />
pWnd = (CWnd*)GetDlgItem(IDC_COMBO_COLUMN);<br />
pWnd->ShowWindow(SW_HIDE);<br />
pWnd = (CWnd*)GetDlgItem(IDC_EDIT_COLUMNVALUE);<br />
pWnd->ShowWindow(SW_HIDE);<br />
pWnd = (CWnd*)GetDlgItem(IDC_STATIC2);<br />
pWnd->ShowWindow(SW_HIDE);<br />
pWnd = (CWnd*)GetDlgItem(IDC_STATIC_SORT);<br />
pWnd->ShowWindow(SW_HIDE);<br />
pWnd = (CWnd*)GetDlgItem(IDC_STATIC_VALUE);<br />
pWnd->ShowWindow(SW_HIDE);<br />
pWnd = (CWnd*)GetDlgItem(IDC_COMBO_SORTCOLUMNS);<br />
pWnd->ShowWindow(SW_HIDE);<br />
<br />
m_lstActivations.Clear();<br />
m_editcolumnvalue.SetWindowText("");<br />
m_combocolumn.SetCurSel(0);<br />
<br />
sessionsettings->filtercol_inpat = 0;<br />
sessionsettings->filtervalue_inpat = "";<br />
sessionsettings->selectedrow_inpat = 1;<br />
sessionsettings->sortcol_inpat = 0; <br />
sessionsettings->showed_inpat = showed;<br />
<br />
HICON icon;<br />
icon = (HICON)::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON_SHOW), IMAGE_ICON, 16, 15, LR_DEFAULTCOLOR);<br />
m_btnhideshow.SetIcon(icon);<br />
<br />
m_lstActivations.MoveWindow(0 + 15 - 3, topoflisthidden, widthoflist-1, bottomoflisthidden);<br />
showed = true;<br />
}
else{<br />
if(m_combosort.GetCurSel() != -1){<br />
sortcol = m_combosort.GetCurSel() + 2;
}
m_lstActivations.MoveWindow(0 + 15 - 3, topoflistshown, widthoflist-1, bottomoflistshown);<br />
CWnd *pWnd;<br />
pWnd = (CWnd*)GetDlgItem(IDC_COMBO_COLUMN);<br />
pWnd->ShowWindow(SW_SHOW);<br />
pWnd = (CWnd*)GetDlgItem(IDC_EDIT_COLUMNVALUE);<br />
pWnd->ShowWindow(SW_SHOW);<br />
pWnd = (CWnd*)GetDlgItem(IDC_STATIC2);<br />
pWnd->ShowWindow(SW_SHOW);<br />
pWnd = (CWnd*)GetDlgItem(IDC_STATIC_SORT);<br />
pWnd->ShowWindow(SW_SHOW);<br />
pWnd = (CWnd*)GetDlgItem(IDC_STATIC_VALUE);<br />
pWnd->ShowWindow(SW_SHOW);<br />
pWnd = (CWnd*)GetDlgItem(IDC_COMBO_SORTCOLUMNS);<br />
pWnd->ShowWindow(SW_SHOW);<br />
<br />
HICON icon;<br />
icon = (HICON)::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON_HIDE), IMAGE_ICON, 16, 15, LR_DEFAULTCOLOR);<br />
m_btnhideshow.SetIcon(icon);<br />
<br />
sessionsettings->showed_inpat = showed;<br />
m_editcolumnvalue.SetFocus();<br />
showed = false;<br />
}
m_btnhideshow.SetButtonStyle(BS_PUSHLIKE|WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_ICON|BS_TOP|BS_LEFT);<br />
m_PrintList.SetButtonStyle(BS_PUSHLIKE|WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_ICON|BS_TOP|BS_LEFT);<br />
HICON printicon;<br />
printicon = (HICON)::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON_PRINT), IMAGE_ICON, 16, 15, LR_DEFAULTCOLOR);<br />
m_PrintList.SetIcon(printicon);<br />
<br />
CRect rect, rect1, rect2, rect3;<br />
CWnd* pWnd;<br />
pWnd = (CWnd*)GetDlgItem(IDC_LIST_ACTIVATIONS);<br />
pWnd->GetClientRect(rect1);<br />
rect3.bottom = 16 + 5;<br />
rect3.top = 5;<br />
rect3.right = rect1.right;<br />
rect3.left = rect1.right - 16;<br />
m_PrintList.MoveWindow(rect3, TRUE);<br />
m_PrintList.GetClientRect(rect2);<br />
rect.bottom = 16 + 5; <br />
rect.top = 5;<br />
rect.right = rect1.right - rect2.right - 5;<br />
rect.left = rect1.right - rect2.right - 5 - 16;<br />
m_btnhideshow.MoveWindow(rect, TRUE);<br />
UpdateWindow();<br />
if(initializing == false){<br />
OnRefresh();<br />
}
<br />
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I want to implement Client/Server Application between Windows and Solaris Machine.Client can communicate to different Solaris Machines.How to handle Multiple socket connections and all socket connections I want run as threads.
Can give any idea or any examples please.
|
|
|
|
|
hi ,
Ur question does not describe the context in which ur running ur application.
I am assuming that ur running a custom TCP/IP server seevice on a solaris
machine. (Otherwise , how ur Client will communicate to Solaris machine ?)
And client machine seems to be windows.
If u take any book on socket programming , that will show u how u can
write a rudimentary server ( some books even deal with HTTP servers )
Basic idea is as follows
ur server will wait for the connection. There are steps
like calling socket function , binding the socket with protocol port address
etc.
When a client initiates a call to the server. Server will create
a new thread or task ( using posix threads package or unix fork function )
and the new request will be handled by the threads. So learn Berkely socket API , Posix threads , Unix fork etc. And try to refer following books
Unix network programming by Richard stevens is the place to go for
Linux / Unix programmers
Winsock programming by Lewis napper will give u idea about Windows socket programming
U can also read Interetworking with TCP/IP by Douglas comer. A chapter on socket programming is there.
Praseed Pai
www.praseedpai.com
|
|
|
|
|
Thank u for reply.I gave lot of inputs to me.I implemented Single threaded Apps.Now that I want convert into multithreading.I was getting Segmentation Fault (core dumped) error.pl tell me How to avoid this?
Thanks in advance
dadsadasd
|
|
|
|
|
Sorry Correction in last reply.Instead of I replace with U.
dadsadasd
|
|
|
|
|
Hello 2all!
I've a simple problem (hopefully):
My visual c++ application have to map a smb share (like typing "net use z: \\server1\c$ ...") at the DOS-prompt. How do I figure this out?
I've tried out the shellexec command but this isn't working properly.
Is there another method to access files lying on a smb share directory on a server?
- Jan
|
|
|
|
|
Look at the WNetAddConnection() , WNetAddConnection2() and WNetAddConnection3() functions on MSDN.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
HI,
I want send and recive Data on Printer Port
how ???
any sample code help
thanx
|
|
|
|
|
i have built an application which was running fine till now as administrator. now, i tried running it as a user, it failed. Does a user do not have access to C:\WINNT\system32\drivers files. actually i am loading a driver(.sys) in my application. so when it runs as a user(other than administrator), it fails to load the driver. but it is very important that all the user logged on to the machine can run the application. also i do not want to move the driver from the C:\WINNT\system32\drivers directory. Is there any way out?
|
|
|
|
|
Hi guys
I'm trying to change my mouse icon when it's passing over a zone in a Picture Control but unsuccesfully.Could you explain me what steps I have to do to implement this?
I'm trying with OnMouseMove to control the zone,and it detects perfectly my zone, but once there, how can I change my mouse icon (remember that is not a button it's a Picture control).I've tried a LoadIcon unsuccesfully.
Thanks in advance.
Doc
|
|
|
|
|
use m_nActiveCursor as a member to store the ID of the cursor which has to be shown
int the OnMouseMove change the cursor as you do using:
SetCursor(LoadCursor( AfxGetInstanceHandle(), MAKEINTRESOURCE(m_nActiveCursor)) );
Also set the cursor in the OnSetCursor correct.
SetCursor(LoadCursor( AfxGetInstanceHandle(), MAKEINTRESOURCE(m_nActiveCursor)) );
Hope this helps.
|
|
|
|
|
Hi GDavy
Still nothing happens
When the mouse is over the zone, still the arrow is shown
void CLinksCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
if ((point.x>7)&&(point.x<188)&&(point.y>0)&&(point.y<23)) {
m_nActiveCursor=1; //HAND
} else {
m_nActiveCursor=32512; // DEFAULT ARROW
}
SetCursor(LoadCursor( AfxGetInstanceHandle(), MAKEINTRESOURCE(m_nActiveCursor)));
CStatic::OnMouseMove(nFlags, point);
}
BOOL CLinksCtrl::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
SetCursor(LoadCursor( AfxGetInstanceHandle(), MAKEINTRESOURCE(m_nActiveCursor)));
return CStatic::OnSetCursor(pWnd, nHitTest, message);
}
Something wrong?
Thanks
Doc
|
|
|
|
|
return TRUE in the OnSetCursor function... ( NOT return CStatic::OnSet...)
Regards
|
|
|
|
|
Sorry
Same result
I'll keep trying
Maybe some Control Property or not?
Thanks
Doc
|
|
|
|