|
Newbie question here...
I am learning c++ and following through the code from a book - which recommends using Microsoft VC++ 7.0. The book stresses that it does not use the .net framework.
My question is can i use VS 2003 (.net) to create a "NON"-.net application? Would this be a "Win32 App" in visual studio?
help?
Thanks.
SN
|
|
|
|
|
Of course!! I've only experimented with the managed extensions a few times, but other than that, I just like the .Net IDE a lot better than VC6's. You can make any of the same application types that you could in VC6. And so far, any code or functions that I had in VC6 work with no problem. The difference if you just want to write C++ code without the .Net stuff is invisible to me. But at any time you can go into your project's properties and set 'Use Managed Extensions' to YES, which adds a \clr switch to your linker settings.
[insert witty comment here]
bdiamond
|
|
|
|
|
Thanks bdiamond! That's good to know.
What exactly are Managed Extensions?
SN
|
|
|
|
|
What exactly are Managed Extensions?
.net stuff...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Managed extensions is the .Net BCL (Base Class Library). I guess it's almost like .Net's version of MFC. There is a great beginner's book I have by Tom Archer and Nishant Sivakumar (whom are both CodeProject members) that deals with a C++ programmer learning to use managed extensions. It's a great book, but I really haven't had the time to do more than a few exercises from it in the past few months.
[insert witty comment here]
bdiamond
|
|
|
|
|
Now i am a little confused....
"...at any time you can go into your project's properties and set 'Use Managed Extensions' to YES..."
As you posted earlier, i need to set 'Use Managed Extensions' to YES, but here you also say they are the .Net BCL.
If so wouldn't i NOT want to use Managed Extensions?
I'm being fussy i know... I just want to be sure i understand!
SN
|
|
|
|
|
I have a function that is handled for my listbox's double-click event. When a file in the list is double clicked it is opened in its default application. It was suggested by one of the users that I make this file read-only after it was opened so that if the user tried to then save a modification they would be reminded. Since the file is saved in the database, when my app closes, it goes through the temp folder and deletes all files that were open during this session. In case I also made it where it'll remove the read-only attribute and delete it if it's already there. The problem is that the BYTE buffer I allocate with the new operator is causing a memory leak, and when I try to call delete on it, I get an error in this section of code in "comip.h":
~_com_ptr_t() throw()<br />
{ <br />
_Release(); <br />
}
here's my function, with offending lines in bold:
BeginWaitCursor();
_RecordsetPtr rst;
strWhere.Format("LinkID = %d",data);
rst = theApp.GetRecordset(_T("*"),_T("tblLink") ,strWhere);
CString str,strPath;
FieldsPtr pFields = rst->GetFields();
FieldPtr pField,pName;
pField= pFields->GetItem(_T("FileBytes"));
pName = pFields->GetItem(_T("Link"));
unsigned long nLength = pField->GetActualSize();
str.Format("%s",(char*)_bstr_t(pName->Value));
_variant_t varBLOB = pField->GetChunk(nLength);
pBuf = new BYTE[nLength];
SafeArrayAccessData(varBLOB.parray,(void **)&pBuf);
pBytes = pBuf;
SafeArrayUnaccessData(varBLOB.parray);
::GetModuleFileName(NULL,szPath,512);
strPath.Format("%s",szPath);
int pos = strPath.ReverseFind('\\');
strDirectory = strPath.Left(pos + 1) + "temp\\";
strPath = strDirectory + url;
CreateDirectory(strDirectory,NULL);
CFile file;
CFileException ex;
CFileStatus status;
status.m_attribute = 0;
if(file.Open(strPath,CFile::modeRead,&ex))
{
file.Close();
CFile::SetStatus(strPath,status);
DeleteFile(strPath);
}
if(file.Open(strPath,CFile::modeCreate | CFile::modeWrite,&ex))
{
file.Write(pBytes,nLength);
file.Close();
file.GetStatus(status);
status.m_attribute |= 0x01;
CFile::SetStatus(strPath,status);
int iReturn = (int) ShellExecute(NULL, _T("open"), strPath, NULL, NULL, SW_SHOWNORMAL);
if (iReturn <= 32)
MessageBox (_T("Cannot open file. File may have been moved or deleted."), _T("Error!"), MB_OK | MB_ICONEXCLAMATION) ;
if(url.GetLength()==0)
MessageBox (_T("This is an empty entry! Try clicking a filled link! "), _T("Error!"), MB_OK | MB_ICONEXCLAMATION) ;
}
else
{
AfxMessageBox("File could not be opened from this location.\r\n"
"Check to make sure you don\'t already have this attachment open.",MB_ICONINFORMATION);
}
}
MYCATCHALL
url.ReleaseBuffer();
EndWaitCursor();
[insert witty comment here]
bdiamond
|
|
|
|
|
Hi,
Does anyone know how to write a text string on a video stream captured with the DirectX libraries in a way that the text is embedded in the stream ? In other words, it is possible to apply a text overlay on a video stream that will be saved with the stream ?
Any help would be greatly appreciated,
John
|
|
|
|
|
Hi,
Does anyone know how to write a text string on a video stream captured with the DirectX libraries in a way that the text is embedded in the stream ? In other words, it is possible to apply a text overlay on a video stream that will be saved with the stream ?
Any help would be greatly appreciated,
John
|
|
|
|
|
Hi i am tyring to build the sample console app using Zlib compression library.
I am getting linker error for following functions.
int __cdecl inflate_trees_fixed(...)<br />
void __cdecl zcfree(void *,void *)<br />
void * __cdecl zcalloc(void *,unsigned int,unsigned int)
for the first function inflate_trees_fixed(...) there is no function prototype in any of the file.
but it has following code in zconf.h file
<br />
#if defined(__MVS__)<br />
# pragma map(inflate_trees_free,"INTRFR")<br />
#endif <br />
AFAIK, if you are using #pragma map then you need not to define the function prototype.
Can someone throw light on this.
Thanks in advance.
Abhi Lahare
|
|
|
|
|
I have a listCtrl in report mode. Now I display a dialog to display/edit items when I double-click on an item in the list.
The problem is I would like to return to the dialog but with the selected item clearded down.
Currently as soon as I click on the dialog the last item is selected. I am using LVS_EX_FULLROWSELECT, so the full row is always selected.
Simply how do I unselect the selected row?
|
|
|
|
|
You need to clear that items selected state.
If you are using MCF:
m_LI.SetItemState (nItem, LVIS_SELECTED, LVIS_SELECTED);
m_LI.SetItemState (nItem, 0, LVIS_SELECTED);
m_LI.Invalidate ();
Otherwise:
LVITEM lvi;
memset (&lvi, 0, sizeof (lvi));
lvi.mask = LVIF_STATE;
lvi.stateMask = LVIS_SELECTED;
lvi.state = bSelected ? LVIS_SELECTED : 0;
SendMessage (hWndLI, LVM_SETITEM, 0, (LPARAM) &lvi);
Does that help?
Iain.
|
|
|
|
|
sweep123 wrote:
The problem is I would like to return to the dialog...
From where?
sweep123 wrote:
...the selected item clearded down.
What does "clearded down" mean?
sweep123 wrote:
Simply how do I unselect the selected row?
Call SetItemState(nItem, 0, LVIS_SELECTED) .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
sweep123 wrote:
The problem is I would like to return to the dialog...
From where?
A Modeless Dialog (edit some fields on this row)
sweep123 wrote:
...the selected item clearded down.
What does "clearded down" mean?
When I next click on the dialog with the listctrl the last item is still selected.
sweep123 wrote:
Simply how do I unselect the selected row?
Call SetItemState(nItem, 0, LVIS_SELECTED).
That works when I display the Modeless dialog - thanks.
One other question, how do I force a complete redraw to the listctrl; say I need to show many changes?
Thanks for you post.
|
|
|
|
|
sweep123 wrote:
One other question, how do I force a complete redraw to the listctrl; say I need to show many changes?
If the items are kept in a data structure of some sort, you can just clear the contents of the list control and re-add them from the data structure. If you are just editing one item at a time, call SetItemText() after the modeless dialog is dismissed.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks again for your post.#
I endd up using Invalidate() to redraw the list following data changes in the structure.
I use SetItemText for small changes.
I dont know if Invalidate() is OK to use.
|
|
|
|
|
i am trying to compling an oci program but keep getting these error messages:
Linking...
cdemorid.obj : error LNK2001: unresolved external symbol _OCIDescriptorAlloc
cdemorid.obj : error LNK2001: unresolved external symbol _OCIHandleAlloc
cdemorid.obj : error LNK2001: unresolved external symbol _OCILogon
cdemorid.obj : error LNK2001: unresolved external symbol "int __cdecl init_handles(struct OCIEnv * *,struct OCIError * *,int)" (?init_handles@@YAHPAPAUOCIEnv@@PAPAUOCIError@@H@Z)
cdemorid.obj : error LNK2001: unresolved external symbol _OCIEnvInit
cdemorid.obj : error LNK2001: unresolved external symbol _OCIInitialize
cdemorid.obj : error LNK2001: unresolved external symbol _OCIHandleFree
cdemorid.obj : error LNK2001: unresolved external symbol _OCILogoff
cdemorid.obj : error LNK2001: unresolved external symbol _OCIErrorGet
cdemorid.obj : error LNK2001: unresolved external symbol _OCIAttrGet
cdemorid.obj : error LNK2001: unresolved external symbol _OCIStmtFetch
cdemorid.obj : error LNK2001: unresolved external symbol _OCIDefineByPos
cdemorid.obj : error LNK2001: unresolved external symbol _OCIStmtExecute
cdemorid.obj : error LNK2001: unresolved external symbol _OCIAttrSet
cdemorid.obj : error LNK2001: unresolved external symbol _OCIStmtPrepare
cdemorid.obj : error LNK2001: unresolved external symbol _OCIBindByPos
Debug/cdemorid.exe : fatal error LNK1120: 16 unresolved externals
Error executing link.exe.
cdemorid.exe - 17 error(s), 1 warning(s)
|
|
|
|
|
did you well included the headers in the source files, and don't you use in you project some extern variables ?
TOXCCT >>> GEII power
|
|
|
|
|
Hi ,
I use MVC++ editor for my vc++ program. When I try to debug it, it shows the point where an exception occured in the assembly language (Disassmebly). I dont know how to convert and find where it happened in the actual code.
what do I do to find where the exception occured in my actual code?
Thanks,
Deepak Samuel.
|
|
|
|
|
Use "Call Stack" to view history of function calls leading to exception.;)
ARSALAN MALIK
|
|
|
|
|
you cannot debug a program compiled in "Release Mode". if you have the source, use the call stack (as said previously) or place some breakpoints where you want to stop the execution, but be SURE you are compiling in "DEBUG MODE ".
you could also click on the rebuild all menu item ; sometimes, it is useful 'cause VC++ fails in its links.
Otherwise, two choices for you : first of them, you learn pentium assembly
second one, you let the program with its bugs and throw it to the trash...
TOXCCT >>> GEII power
|
|
|
|
|
hello sir
I am working on disk imaging. I am able to read the hard disk and getting its image in a file and in a buffer.I am also able to write this image back. but i want to connect an image of hard disk as a virtual logical disk.So that i am able to cut, copy data from that virtual drive. Plz help me by giving programming clue and solution of this problem.
With best regards
darpan kamboj
|
|
|
|
|
Hi
There are many Win32 APIs that when passed with a NULL returns the size of the buffer it is expecting (say- GetLogicalDriveStrings).
The question is which one would be better.
1. Create a reasonable sized array and call api.
2. Call the API twice and then allocate.
Regards
Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
I'm yet to see the speed of a program be affected by doing twice API calls: most slow code I've seen was because of bad coding practices (aka messy, ill-written and structured code) or because of poor algorithms.
Answering your question: you don't need to pass NULL on the first call - you can use a reasonable sized array. Then, if the call fails because of the buffer size, you can retry it with a bigger buffer.
Yes, even I am blogging now!
|
|
|
|
|
Premature optimization is the root of all evil. (in programing)
Do not ask this question unless you have your app mostly completed, it is running too slow, and you have determined that calls to one particular API are taking too long!
In general if you know the size of data you need it doesn't matter if the API can return more, just ask for how much of it you will need. If you don't know, then pick one of the two.
|
|
|
|