|
yanping wang wrote:
want to transfer file between two hosts in different LANs, but there are NATs.
You will need a central server to do that
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
yes. are there any code or articles about that?
|
|
|
|
|
Hi,
How to make command UI fuctions like;
pCmdUI->SetText,
pCmdUI->Enable,
pCmdUI->SetCheck to work when we have a menu in dialog?
Currently it works for menus in SDI/MDI's but not in dialogs
|
|
|
|
|
Manikandan wrote:
How to make command UI fuctions like;
pCmdUI->SetText,
pCmdUI->Enable,
pCmdUI->SetCheck to work when we have a menu in dialog?
Currently it works for menus in SDI/MDI's but not in dialogs
Check this post[^]
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Thanks Jose.
I also found a easy way to do this something as below,
// Get the popup menu which contains the "Lock" menu item.
CMenu* mmenu = GetMenu();
CMenu* submenu = mmenu->GetSubMenu(2);
submenu->CheckMenuItem(ID_LOCK, (m_bLock)?MF_CHECKED : MF_UNCHECKED | MF_BYCOMMAND);
|
|
|
|
|
Well, that's a different approach. It means that whenever (and wherever) you change m_bLock, you have to get to the menu item and change it.
The other approach goes the other way, whenever the menu needs to be shown (and only then), you get the chance to alter its state (enable, check, text, etc.). Besides, it's a general mechanism you can use for any menu item.
But I agree that, if that's the only menu item you need to change and if m_bLock is only changed in a single place, your method is simpler
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
I am calling an .exe using ShellExecute in VC++ application in a thread, how do I find out its Process ID
mi
|
|
|
|
|
Use ShellExecuteEx to find out the handle to the process and then use GetProcessId to find out the corresponding process id.
Don't try it, just do it!
|
|
|
|
|
Thanks for the reply but I could not find GetProcessID in msdn. Also could you please tell me how to use ShellExecuteEx.
mi
|
|
|
|
|
Hi,
I am using ADSI api and want to extract Net BIOS name from DNS using C++.
I got following sample from MSDN. But this sample is not compiling. I got following compilation error:
error C2065: 'IADsNameTranslate' : undeclared identifier
I have Included "activeds.h" and "Iads.h" in the header files but still I am not able to get the desired result.
If someone has worked on it then please sent me the working code.
#include "activeds.h"
#include "Iads.h"
int wmain( int argc, wchar_t *argv[] )
{
IADsNameTranslate *pNto;
HRESULT hr;
hr = CoCreateInstance(CLSID_NameTranslate,
NULL,
CLSCTX_INPROC_SERVER,
IID_IADsNameTranslate,
(void**)&pNto);
if(FAILED(hr)) { exit 1;}
hr = pNto->InitEx(ADS_NAME_INITTYPE_SERVER,
CComBSTR("aDsServer"),
CComBSTR("aUser"),
CComBSTR("userDomain"),
CComBSTR("passwd"));
if (FAILED(hr)) { exit 1;}
hr =pNto->Set(ADS_NAME_TYPE_1779,
CComBSTR("cn=jeffsmith,cn=users,dc=Fabrikam,dc=com"));
if(FAILED(hr)) {exit 1;}
BSTR bstr;
hr = pNto->Get(ADS_NAME_TYPE_NT4, &bstr);
printf("Translation: %S\n", bstr);
SysFreeString(bstr);
pNto->Release();
}
Thanks and Regards
Ankur
Regards... Ankur
|
|
|
|
|
Which compiler are you using ?
You might find that is isn't valid for Visual C++ 6.0, just for the .NET versions.
Elaine
The tigress is here
|
|
|
|
|
Thanks for your reply
I am using vc++ compiler.
Actually my requirement is to extract Net BIOS name from DNS.
For this I was planning to use IADsNameTranslate object.
Can you tell me any workaround for implementing this functionallity in VC++ 6.0
Please respond asap.Its Urgent
Thanks and Regards
Ankur
|
|
|
|
|
Hello i got an assignment to do on classes, basically i got 90% of the program working except for some minor issues which i cant seem to figure out.
Here is the code:
#include <iostream.h>
#include <assert.h>
#include <cstring>
class weather
{
private:
int day;
int month;
int year;
int temp;
int humid;
char *condition;
void leapyear(int);
public:
weather(int =1,int =99,int =54,int =100,int =33,char*= "Elie"); //Problem
~weather();
void setall(int,int,int,int,int,char*);
int get_day();
int get_month();
int get_year();
int get_temp(int);
int get_humid();
void print();
void get_condition();
};
weather::weather(int x,int y,int z,int t,int h,char *k)
{
setall(x,y,z,t,h,k)
};
weather::~weather()
{ delete condition;}
void weather::setall(int a,int b,int c,int d,int e,char *f)
{
{if (a<1 ||a>31)//day
day=1;
else
day=a;}
{if (b<1 || b>12)//month
month=1;
else
month=b;}
{if(c<1900||c>2005)//year
year=2000;
else
year=c;}
{if (d<60||d>60)//temp
temp=20;
else
temp=d;}
{if (e<0||e>100)//humid
humid=55;
else
humid=e;}
condition=new char[strlen(f)+1];
assert (condition!=0);
strcpy(condition,f);
}
int weather::get_day()
{return day;}
int weather::get_month()
{return month;}
int weather::get_year()
{return year;}
int weather::get_temp(int t)
{ t=0;
t=((9/5)*temp)+32;
return t;
}
int weather::get_humid()
{return humid;}
void weather::leapyear(int a)
{
a=year;
if (a%4==0 && a%100!=0)
cout<<"This is a leap year"<
|
|
|
|
|
Take more time debuging your program and arrange everything so u can read it better and understand it.
Anyway enjoy here is ur new code and it is working.
#include <iostream.h>
#include <string.h>
#include <assert.h>
class weather
{
private:
int day;
int month;
int year;
int temp;
int humid;
char *condition;
void leapyear(int);
public:
weather(int =1,int =99,int =54,int =100,int =33,char* a="Elie"); //Problem
~weather();
void setall(int,int,int,int,int,char*);
int get_day();
int get_month();
int get_year();
int get_temp(int);
int get_humid();
void print();
void get_condition();
};
weather::weather(int x,int y,int z,int t,int h,char *k)
{
setall(x,y,z,t,h,k);
}
weather::~weather()
{
delete condition;
}
void weather::setall(int a,int b,int c,int d,int e,char *f)
{
if (a<1 ||a>31)//day
{
day=1;
}
else
{
day=a;
}
if (b<1 || b>12)//month
{
month=1;
}
else
{
month=b;
}
if(c<1900||c>2005)//year
{
year=2000;
}
else
{
year=c;
}
if (d<60||d>60)//temp
{
temp=20;
}
else
{
temp=d;
}
if (e<0||e>100)//humid
{
humid=55;
}
else
{
humid=e;
}
condition=new char[strlen(f)+1];
assert (condition!=0);
strcpy(condition,f);
}
int weather::get_day()
{
return day;
}
int weather::get_month()
{
return month;
}
int weather::get_year()
{
return year;
}
int weather::get_temp(int t)
{
t=0;
t=((9/5)*temp)+32;
return t;
}
int weather::get_humid()
{
return humid;
}
void weather::get_condition()
{
cout<<condition;
}
void weather::leapyear(int a)
{
a=year;
if (a%4==0 && a%100!=0)
{
cout<<"This is a leap year"<<endl;
}
else
{
cout<<"This is not a leap year"<<endl;
}
}
void weather::print()
{
cout<<"On the: "<<day<<"/"<<month<<"/"<<year<<endl;
cout<<"-------------------------------------------------------"<<endl;
cout<<"Temperature is: "<<temp<<endl;
cout<<"Humidity (in %) is: "<<humid<<endl;
cout<<"Condition is "<<condition<<endl;
}
void main()
{
weather a;
a.print();
}
/\(-)|\/|/\|)
|
|
|
|
|
elie_h wrote:
Can anyone please compile it and tell me where my mistakes are.
What statements are in error?
For future posts, surround your code with <pre> tags. This will help in the readability department.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi,
Anyone got source code to change SQl Server startup account to SA.
I need this to be run during my installation.
Thanks,
Toms
|
|
|
|
|
Hi,
I'm building an MFC app (not everyone has moved to .NET yet, in fact I have decided to skip .NET and wait for the next framework, due any time now)that has a splitter window with two main panes, left and right. In each pane I have a tab control. The left tab control has a tree control in each tab. The right tab control will have different controls in each tab, depending upon the selection in the left tab control's selected tree and item.
That's all fairly specific, but my question is quite general. What is the best way to cause events in one pane of a splitter (in the case selecting a treeitem) to make things happen in another pane. In a more simple example, how would events in the left view cause changes to the right view?
I ask this because normally views do not know about each other, only about their parent frame. What's the most elegant way to link the views? (NB, I'm not asking what are the tree notification events, I know those).
|
|
|
|
|
Mister Transistor wrote:
That's all fairly specific, but my question is quite general. What is the best way to cause events in one pane of a splitter (in the case selecting a treeitem) to make things happen in another pane. In a more simple example, how would events in the left view cause changes to the right view?
I ask this because normally views do not know about each other, only about their parent frame. What's the most elegant way to link the views? (NB, I'm not asking what are the tree notification events, I know those).
Both views are linked to the same CDocument, right? I'd follow the same approach as for document data changes in general.
I'd add the following to the document:
1. some member to represent the shared state (i.e.: 'selected item')
2. a member function to get the shared state
3. a member function to alter the shared state
4. an enum with identifiers to be used in UpdateAllViews notifications, including an identifier for "shared state changed".
Then, the view that changes the selected item simply calls the method in 3, which is implemented as follows:
class YourDocument : public CDocument
{
[...]
public:
enum UpdateHints {ANY_CHANGE, SELECTED_ITEM_CHANGED, ...};
void YourDocument::ChangeSelectedItem(ItemIdentifier item, CView* pRequestingView = NULL);
};
void YourDocument::ChangeSelectedItem(ItemIdentifier item, CView* pRequestingView )
{
m_itSelected = item;
UpdateAllViews(pRequestingView, SELECTED_ITEM_CHANGED, NULL);
}
The OnUpdate implementation for the right view can do something like:
void RightView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
switch (lHint)
{
default:
Invalidate();
break;
case YourDocument::SELECTED_ITEM_CHANGED:
OnSelectedItemChanged();
break;
[...]
}
}
void RightView::OnSelectedItemChanged()
{
[...]
[...]
}
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose,
many thanks, your proposal is logical and relatively simple and elegant - I like it!
regards
Andrew
|
|
|
|
|
Does anyone know how to create a version info, using VERBLOCK and VERHEAD
I need to create my own version resource and call updateresource to put in new values into an executeable
(ie. making Comments, InternalName, OriginalFilename, ... etc)
ANY HELP WOULD BE APPRECIATED sample code ><
Thanks
Mepho
|
|
|
|
|
This type of resource is usualy not to be modified once you set it. Why would you want to change it from within your program ? I use the following code lines in the "resource.rc" file:
#ifndef _MAC
////////////////////
// Version Info
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0
PRODUCTVERSION 0,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
{
BLOCK "StringFileInfo"
{
BLOCK "041804b0"
{
VALUE "Comments", "<text>\0"
VALUE "CompanyName", "<text>\0"
VALUE "FileDescription", "<text>\0"
VALUE "FileVersion", "0.0.0.0\0"
VALUE "InternalName", "<text>\0"
VALUE "LegalCopyright", "<text>\0"
VALUE "LegalTrademarks", "<text>\0"
VALUE "OriginalFilename", "<text>\0"
VALUE "PrivateBuild", "0\0"
VALUE "ProductName", "<text>\0"
VALUE "ProductVersion", "0.0.0.0\0"
// here you can insert other values of your own, like:
// VALUE "DISCLAIMER", "Your own Disclaimer\0"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x418, 1200
}
}
#endif // !_MAC
|
|
|
|
|
Hi there ! I want to load a bitmap from inside my application in order to display it on a dialog box !
In "resource.h" file i wrote:
"#define IDB_BITMAP_SPLASH 500"
In "resource.rc" file i wrote:
"IDB_BITMAP_SPLASH BITMAP "SPLASH.BMP", where SPLASH.BMP is the name of my bitmap file.
In "main.cpp" file i wrote:
"HBITMAP hBitmap=(HBITMAP)LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BITMAP_SPLASH));", where "hInst" is my application's instance handle.
The problem is that this function is returning NULL. I've also tried with "LoadImage()" and "LoadResource()" functions. None of them work ! I've tried instead of MAKEINTRESOURCE to simply write "Splash.bmp" as if i were loading it directly from the file. Does not work !
Can anyone help me ? I'm using Windows 2000 SP4 and i'm not writing this in MFC, but in simple Win32API.
ThankYou !!!
|
|
|
|
|
|
I use Bloodshed Dev-C++ IDE with MINGW compiler, so i don't have a resource editor !
|
|
|
|
|
ThEdreamMaker wrote:
"HBITMAP hBitmap=(HBITMAP)LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BITMAP_SPLASH));", where "hInst" is my application's instance handle.
The problem is that this function is returning NULL
Have you checked GetLastError() ?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|