|
hi
can u give the code on how to do it
Chethan
|
|
|
|
|
How can I add more two projects to my current project, and make default project to run ?
Thanks in advance
|
|
|
|
|
Right click and choose add project. Right click on the project you want to run and choose 'make this the default project'.
Something like that. More specific instructions would require knowledge of the version of the IDE you are using.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hcmuns wrote:
two projects to my current project
I don't think you can do that, you can however add more projects to your solution / workspace the way Christian explained.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
I encountered the problem when I was use the CToolBar Class.
Code as followed:
//add three static ,three EDIT,a button
CRect rectSlogo,rectSaddr,rectEaddr,rectSname,rectEname,rectSpass,rectEpass,rectBlogin;
//set index
//m_wndToolBar.SetButtonInfo(0,IDC_STATIC_LOGO,TBBS_SEPARATOR,32);
m_wndToolBar.SetButtonInfo(1,IDC_STATIC_ADDR,TBBS_SEPARATOR,60);
m_wndToolBar.SetButtonInfo(2,IDC_EDIT_ADDR,TBBS_SEPARATOR,200);
m_wndToolBar.SetButtonInfo(4,IDC_STATIC_NAME,TBBS_SEPARATOR,60);
m_wndToolBar.SetButtonInfo(5,IDC_EDIT_NAME,TBBS_SEPARATOR,70);
m_wndToolBar.SetButtonInfo(7,IDC_STATIC_PASS,TBBS_SEPARATOR,60);
m_wndToolBar.SetButtonInfo(8,IDC_EDIT_PASS,TBBS_SEPARATOR,70);
m_wndToolBar.SetButtonInfo(10,ID_BUTTON_LOGIN,TBBS_SEPARATOR,40);
//m_wndToolBar.GetItemRect(0,&rectSlogo);
m_wndToolBar.GetItemRect(1,&rectSaddr);
m_wndToolBar.GetItemRect(2,&rectEaddr);
m_wndToolBar.GetItemRect(4,&rectSname);
m_wndToolBar.GetItemRect(5,&rectEname);
m_wndToolBar.GetItemRect(7,&rectSpass);
m_wndToolBar.GetItemRect(8,&rectEpass);
m_wndToolBar.GetItemRect(10,&rectBlogin);
//set the rect
//rectSlogo.top+=2;
//rectSlogo.bottom+=6;
rectSaddr.top+=2;
rectSaddr.bottom+=6;
rectSname.top+=2;
rectSname.bottom+=6;
rectSpass.top+=2;
rectSpass.bottom+=6;
/*CString str;
char buf[MAX_PATH];
GetCurrentDirectory(260,buf);
str = (CString)buf;
if(!m_staticlogo.Create("logo",WS_CHILD | WS_VISIBLE | SS_BITMAP|SS_CENTERIMAGE,rectSlogo,&m_wndToolBar,IDC_STATIC_LOGO))
{
TRACE0("Create STATIC_LOGO fail!\n");
return false;
}
m_staticlogo.SetBitmap(::LoadBitmap(NULL,str+"\\res\\firefox2.bmp"));
m_staticlogo.ShowWindow(SW_SHOW);*/
if(!m_staticaddr.Create("地址:",WS_CHILD | WS_VISIBLE,rectSaddr,&m_wndToolBar,IDC_STATIC_ADDR))
{
TRACE0("Create STATIC_ADDR fail!\n");
return false;
}
m_staticaddr.ShowWindow(SW_SHOW);
if(!m_editaddr.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL ,rectEaddr,&m_wndToolBar,IDC_EDIT_ADDR))
{
TRACE0("Create EDIT_ADDR fail!\n");
return false;
}
m_editaddr.ShowWindow(SW_SHOW);
if(!m_staticname.Create("用户名:",WS_CHILD | WS_VISIBLE,rectSname,&m_wndToolBar,IDC_STATIC_NAME))
{
TRACE0("Create STATIC_NAME fail!\n");
return false;
}
m_staticname.ShowWindow(SW_SHOW);
if(!m_editname.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL ,rectEname,&m_wndToolBar,IDC_EDIT_NAME))
{
TRACE0("Create EDIT_NAME fail!\n");
return false;
}
m_editname.ShowWindow(SW_SHOW);
if(!m_staticpass.Create("密 码:",WS_CHILD | WS_VISIBLE,rectSpass,&m_wndToolBar,IDC_STATIC_PASS))
{
TRACE0("Create STATIC_PASS fail!\n");
return false;
}
m_staticpass.ShowWindow(SW_SHOW);
if(!m_editpass.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL ,rectEpass,&m_wndToolBar,IDC_EDIT_PASS))
{
TRACE0("Create EDIT_PASS fail!\n");
return false;
}
m_editpass.ShowWindow(SW_SHOW);
if(!m_buttonlogin.Create("登录",WS_CHILD | WS_VISIBLE | BS_CENTER | BS_USERBUTTON ,rectBlogin,&m_wndToolBar,ID_BUTTON_LOGIN))
{
TRACE0("Create BUTTON_LOGIN fail!\n");
return false;
}
m_buttonlogin.ShowWindow(SW_SHOW);
paste the code in OnCreate Function of MainFrm.cpp of a MFC SDI programme.then discard the // in the code above,the ToolBar disappear,
I wonder Why this happened,Please help me!
|
|
|
|
|
I have to be doing something wrong as this is too simple. I have a doc/view project with a LOT of menu items. EnableMenu() isn't working as I want it to. However, I can call the CheckMenuItem member and it works fine in the same SPOT!
This code takes a emumerated list of ALL menu items and checks each menu item. It works perfectly:
<br />
CMenu* pMenu = GetMenu();<br />
<br />
for(int i = 0; mymenuids[i] != ID_SEPARATOR; i++)<br />
pMenu->CheckMenuItem(mymenuids[i], MF_CHECKED);<br />
Now, if I change this to gray all the entries, NONE of them gray\disable:
<br />
CMenu* pMenu = GetMenu();<br />
<br />
for(int i = 0; mymenuids[i] != ID_SEPARATOR; i++)<br />
pMenu->EnableMenuItem(mymenuids[i], MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);<br />
What could possibly be wrong? Possible that a resource file has corrupted? I'm baffled!
Thanks in advance,
Philip
|
|
|
|
|
Each menu item has two events - one when you click it, and the other is called just before a menu item is displayed. This is where you need to set properties like enabled and checked.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ah, good stuff. That worked! Although, I'm not sure why you can't call the enableitems properly outside of the message handler. Oh well.
Thanks for your help
|
|
|
|
|
PhilipGa wrote:
I'm not sure why you can't call the enableitems properly outside of the message handler.
Because the handler resets them, I guess.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello. Looking for some help on using CPropTree from:
http://www.codeproject.com/treectrl/proptree.asp
I'm trying to use CPropTree in my project, as shown in the dlgsample, but I'm not actually sure how to set up the project to use it. Specifically, I'm trying to use do it like the example program that has :
#include <proptree.h> in stdafx.h, but it says it cannot find it. What changes to the project settings do I need to get this to work?
Any thoughts or help would be appreciated.
Thanks.
|
|
|
|
|
Hi,
This question is related to win32 user interface programming.
I need to use Single threaded runtime library and cannot use MFC. Thus I am using win32.
I have designed a dialog that should take three float values as input. How do write the code to do data exchange so that values entered by the user are available to me in some local variable after the user has clicked "OK" on the dialog after entering some values. I can do this in MFC and but do not know how to do this using win32. I could create file open dialog using GetOpenFileName but did not find any similar function for writing data exchange code.
Any help would be great as I am stuck and want to get this done asap.
Thanks in advance for your help.
Regards,
Abhijit
|
|
|
|
|
Use GetDlgItem to get the hwnd of the control
(hWnd is your dialog's hwnd, nIDC is your control's resource id)
HWND hWndCtrl;
::GetDlgItem(hWnd, nIDC, &hWndCtrl);
Use GetWindowText to then get the control's value:
TCHAR szT[64];
::GetWindowText(hWndCtrl, szT, _countof(szT));
|
|
|
|
|
Hi guys
Once again, please excuse me if this is way too simple... oh those newbies...
If I have to read a file with many lines of data, it would be useful for the user to be able to identify any particular entry that wants to be modified. Of course, the code that reads the data (or the manual) tells what it is, but for the user it would be easier if information could be added to the file that has the data with the program ignoring those bits of information. I'd appreciate any simple solution to this.
Thanks a million!
|
|
|
|
|
Do what all languages do - define a character sequence to indicate a comment. For example, in C++, it's // or /* ... */. Use a sequence that makes sense to your users, if they use VB, for example, use '. Then the trick is that any string that is valid and starts with ' needs to start with a known sequence to escape that character ( such as '' ).
The other way to do it is to use XML, and then HTML comments are valid.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
uh... either I didn't make myself clear or I didn't understand your response. Of course I know that INSIDE THE CODE I can use // or /*...*/. The question is how do I comment in a file to be read by the program, making the program ignore the comment... just the same as in the code but while reading the file. Say I have the following code:
int main()<br />
{<br />
int id;<br />
double Stuff;<br />
ifstream GetData;<br />
GetData.open("D:\\SSL\\Code\\Testing_Rutines\\FileComms\\comms.dat");<br />
if (! GetData.is_open())<br />
{ cout << "Error opening data file" << endl; exit (1); }<br />
else cout << "Commented file opened" << endl;<br />
<br />
while(!GetData.eof())<br />
{<br />
GetData >> id >> Stuff;<br />
cout << id << Stuff;<br />
}<br />
GetData.close();<br />
<br />
return 0;<br />
}<br />
And the data file has (with comments):
// first
1 2.3
// second
2 3.5
// third
3 9.8
where the program needs to ignore "// first" , "// second" and "// third".
If your response is that I need to "define a character sequence to indicate a comment" I have absolutely no idea how to do it. Both // and /*...*/ are already defined in C++ as comments inside the code, I don't have to define anything.
Thank you!
|
|
|
|
|
I'm saying that you read the data a line at a time, and check each line for the comment delimiter, and if it is there, ignore it for processing.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
That sounds as if you were recommending to read both the data and the comment and then just ignore/destroy the comment read. If so, that is something I don't want to do. I want to read the data only and if a comment is found ignore it, do not read it.
Thanks!
|
|
|
|
|
Then you're screwed. You can't know that a comment exists without reading it from disc and examining it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
As Christian is saying, if you're going to use a file where you're manually reading every line, then by definition, you'll have to manually parse the comment lines and ignore them. This is one argument for using XML as with XML you can specifically read data-only nodes and not read comment-nodes.
|
|
|
|
|
I allocate a CFileDialog for select and work on a file txt:
CFileDialog ldFile(TRUE, NULL, NULL, OFN_OVERWRITEPROMPT,"Text Files (*.txt)|*.txt||");
After... with data taken from this txt i have to do something with an access db that live in the same dir where the application has been executed:
m_db->Open(NULL, false, false, "ODBC;DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)};DSN='';DBQ=article.mdb");
The problem is that the app search article.mdb in the same dir where the user have been selected the txt file...
How can i do for read the db in the same dir of the app?
|
|
|
|
|
TCHAR buff[MAX_PATH];
GetModuleFileName(NULL, buff, MAX_PATH);
char drive[3];
char dir[MAX_PATH];
char fname[MAX_PATH];
char ext[MAX_PATH];
_splitpath(buff, drive, dir, fname, ext);
|
|
|
|
|
I am writing a C++ DLL that is accessed by a VB form.
The problem I have is that I need to use methods in the DLL that deal with an object that I cannot pass back to the VB form.
So far the only way I have found to get around this problem is by wrapping the C++ class and creating an instance of it, then passing the pointer to that instance back to VB. Whenever VB calls a method it includes the integer (object pointer) in order for the C++ code to reference the instance of the class.
However, I don't want to have to create a wrapper like this. Is there any way for me to make the methods and the objects created in the DLL static so that they can be accessed through multiple method calls from VB without passing this object pointer?
|
|
|
|
|
CimTaurus wrote:
Is there any way for me to make the methods and the objects created in the DLL static so that they can be accessed through multiple method calls from VB without passing this object pointer?
it's tough to say, without knowing how these object[s] are used by your system.
if the VB code only ever uses a single object instance in the C++ code, you could just make the object global in the DLL, and have all method calls use that global object.
DLL
-------------------
global exported
objects: functions:
<-- FooMethod1(...)
CFoo <-- FooMethod2(...)
<-- FooMethod3(...)
<-- BarMethod1(...)
CBar <-- BarMethod2(...)
<-- BarMethod3(...)
-------------------
if you want to operate on multiple instances of the CFoo and CBar objects, though, you'll need a way to distinguish them externally, and in that case, the object pointer is as good as any other method.
what is it about the way you're doing it that you don't like?
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
A project I'm working on has me updating some app generated e-mail code (that used Simple MAPI) so that it can send image attachments that show up inline as part of an html message instead of simply as attachments. I used CDO for this, which worked great once I could finally figure out how it all worked (worst part is most of the MSDN samples were usually missing one key component to get it to work ... grr). I'm almost done, except for one little problem. What I want to do is open the generated e-mail up with the default e-mail program, to allow the user to change the message as they want and put in recipients. But, using the IMessage's Send function, the call will fail unless there is a recipient specified ... in other words, it will only send the message silently, without user interaction.
With simple MAPI, I can simply call SendMail with the MAPI_LOGON_UI|MAPI_DIALOG flags, and it opens up the e-mail in the e-mail client. This works great, and is what the old code used to do. Too bad I can't use this function with the IMessage message.
From what I can see from sample source and other documentation, with pretty much any other language supported by microsoft, the Send function I'm calling has a ShowDialog parameter that allows you to pop-up the dialog like I want it to (I'm so sick of seeing VB examples like this I could just puke). Unfortunately, this function is not available with C++, it only has the one version that takes no parameters.
One line of thought I had was to save the email out as a temporary file, then send open it with a shell command .. but that won't work quite right either, the generated e-mail can be saved as a .eml file, which opens up in Outlook Express ... not the default e-mail program, and even that doesn't quite work the way I intend either.
I've been searching through MSDN and the web for over a day now, and because the functionality is there for other languages, I know there has to be a setting or field I can set to allow this ... but I can't find anything. Anyone go through something similar, or have some other place I can look?
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
how can I load a bitmap from file and display it inside (let's say) a static control?
thank you
|
|
|
|
|