|
Thanks for reply.
Prem Kumar wrote:
Is it abt retrieving the image
from the database or show the
bitmap on the screen ?
What is abt?
Prem Kumar wrote:
If it is abt the retrieving and
assuming that you are using binary
you can use the method GetChunk
to read the binary data from the
database.
My field is Image(OLE Object) and I think you are right.So I have to go and check those articles now.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Mazdak wrote:
What is abt?
I'm guessing it means about
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it" Nish on life [methinks]
"It's The Soapbox; topics are optional" Shog 9
|
|
|
|
|
I'm guessing this is programmer/company specific but what does doumenting your source code usually entail...?
More than comments obviously...?
I was looking at a mechanics manual for an 87 Camaro and thought...how detailed...any moron could figure out how to fix a car (Camaro anyways) using this book as a guide. Then I thought...you could probably do the same for source code you write...step by step explanations and pictures (where appropriate) giving anyone with knowledge in C++ the ability to quickly make changes or fix bugs. After some more thought however...I realized that software changes all the damn time and to keep a book of that size up to date would require to much time. So my question is this...How much time and effort do you spend documenting your source code...???
I've never done this, but i'm starting to develope quite the number of *.cpp files w/ *.h and i'm finding it harder and harder to sift through my code and extract cool code when needed and actually understanding what it does without having to break it down. I'm thinking docs would really help...but i'm at a loss as to how much time one should spend...i'd like to learn from others past experiences and hear what you have to say about the most efficient time useage. I figure...to little and your not gonna understand what your docs are saying later on and too much and your wasting time which could be spent doing somehting else...
Actually I guess I don't figure...it's common sense...
Anyways....this is what I would like to know...keep in mind i'm an individual programmer, not a major CORP. like M$....
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
If done properly the design document you wrote before writing the actual code should be enough. Of course this is an imperfect world. I spend about 60% of my project time writing the design docs and then about 20% doing the actual coding. You have to get into the habit of designing first and then coding. The hardest habit to pick-up is revising your design docs when you make coding alterations.
I tend to approach a project from the point of view of somebody else doing the actual coding, this helps to make your documentation better. It's hard but once you get into the habit, development life is much easier.
Michael
Time flies like an arrow. Fruit flies like a banana
|
|
|
|
|
I wanna use SendMessage() or any other function in my InitInstance() to close application in a condition.But I cant find correct argument for it.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Mazdak wrote:
or any other function
To close the app from InitInstance() , just return FALSE .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Send the message WM_CLOSE to close the app.
[edit] Actually doing what Ravi said is probably better in InitInstance()[/edit].
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it" Nish on life [methinks]
"It's The Soapbox; topics are optional" Shog 9
|
|
|
|
|
Brian Delahunty wrote:
Send the message WM_CLOSE to close the app.
I know that.The problem is I don't know the correct form of SendMessage in InitInstance.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Whats wrong with this:
COleSafeArray arrayField;
arrayField.CreateOneDim(VT_VARIANT,6);
COleSafeArray arrayValues;
arrayValues.CreateOneDim(VT_VARIANT,6);
arrayField.PutElement((long *)0, &(_variant_t("LastName")));
arrayValues.PutElement((long *)0,&(_variant_t("Mansouri")));
Atg the PueElement statement it thrown an exception.But I can't see the error.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
hi,
if you use a function like this where you give in strValue your "Lastname"
void FillSafeArray(CString strValue, int iRow, int iCol, COleSafeArray* sa)
{
VARIANT v;
long index[2];
index[0] = iRow;
index[1] = iCol;
VariantInit(&v);
v.vt = VT_BSTR;
v.bstrVal = strValue.AllocSysString();
sa->PutElement(index, v.bstrVal);
SysFreeString(v.bstrVal);
VariantClear(&v);
}
hope it helps,
DanielO
|
|
|
|
|
Thanks.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
If i want to pass numerical value in FillSafeArray(int ivalue...)then what should i change in the FillSafeArray function?
Why i need int value because when i use FillSafeArray(CString strValue..) the value saved in excel sheet as text even though that value is "number". I want the sum of column & since the values are stored in excel as text in 1 column & if sum formula is used for that column in excel automation, it gives sum as 0. Hence i thought of storing this value as int so that am able to use sum formula in excel automation.
Is there any function to convert text to number in excel automation?
|
|
|
|
|
Hello
i have a MDI app derived from CFormView and i want when i "press" a menu item named Alimente to appear a new child window maximized and in it a CListCtrl ... i have tryed this in the my CChildFrame Class ... it appears normally until i try to selectem a list item or to press a column header .. it's really "dead" and when i change the window size the list is becoming erased in some places and the window's scroolbars white ... please help me to be normal and excuse my english
void CChildFrame::OnPersonalAlimente()
{
CProiectApp *aa=(CProiectApp*)AfxGetApp();
CCommandLineInfo cmdInfo;
aa->ProcessShellCommand(cmdInfo);
CMDIChildWnd * bb=((CMDIFrameWnd*)AfxGetMainWnd())->MDIGetActive();
bb->SetWindowText("ha");
WINDOWPLACEMENT vant;
bb->GetWindowPlacement(&vant);
vant.showCmd=SW_SHOWMAXIMIZED;
bb->SetWindowPlacement(&vant);
CRect rct(20,20,400,600);
aa->interfata.m_lcAlimente.Create(LVS_REPORT | LVS_SINGLESEL,rct,bb,567328);
aa->interfata.m_lcAlimente.SetWindowText("Alimente");
aa->interfata.m_lcAlimente.InsertColumn(0,"Aliment",LVCFMT_LEFT,100,0);
}
|
|
|
|
|
Hi.
I am learning about dll. I created a simple dll with one class and one member function that returns a string object. The function looks something like this.
-----
string MyClass::MyFunc()
{
string text = TEXT("Testing 1 2 3");
return text;
}
-----
In the main program, I statatically link the dll to the program. Everything compiles fine. However, the program crashes right after MyFunc().
-----
// Statically link DLL.
#include "MyDLL.h"
void MyWinClass::F1()
{
// Instantiate MyClass as local variable
MyClass oneVar;
// Attempt to get text from oneVar's member function
// MyFunc() should return a string object. It does.
string newText = oneVar.MyFunc();
-----
Everything works up to and including the last line of code. I could even open the text MyFunc() returns. There is a big problem, however; the program crashes.
This is the error Visual C++ shows when the program crashes after calling a function via the DLL.
-----
HEAP[MyProgram.exe]: Invalid Address specified to RtlValidateHeap( 00360000, 00353FA0 )
Unhandled exception at 0x77f7f570 in MyProgram.exe.exe: User breakpoint.
-----
In debug mode, the debugger shows a message box that mentioned something about "_BLOCK_TYPE_IS_INVALID(pHead->nBlockUsed)."
Is there something wrong with the dll? The algorithm above works find if I call MyFunc() from inside another class. It seems that the program is trying to free something after return from the dll.
Thanks,
Kuphryn
|
|
|
|
|
You try to free a memory block, allocated in DLL. It is wrong, because there are two heaps in your APP - first in EXE, 2'nd - in DLL. The memory block, allocated in DLL, must be freed in DLL only! I strongly discourage you to use STL routines with DLL. It is dangerous. You may use next approach instead of your example above
void MyClass::MyFunc(LPTSTR szText)
{
ASSERT(szText);
_tcscpy(szText,TEXT("Testing 1 2 3"));
}
Of course, it is not flexible 'cause you can't resize memory block on the fly in function MyClass::MyFunc, but ... I don't know another way to solve this problem.
May be, it is possible to use some compiler switches... I don't know
|
|
|
|
|
What Roman said is true and "strongly recommended": Always free resources in the same module scope you allocated them. This is simply a question of good and clean design.
Having said that there is also another solution.
The problem arises because you try to free a memory block that has been allocated by a different heap manager. This comes from linking CRT statically to the DLL and the .exe. Each of them, the DLL and the .EXE, have an own instance of the CRT and these two instances do not know anything about each other. Therfore the heap manager in the .exe is not able to free a block allocated via the heap manager in the DLL.
If you link both your app and your DLL against the same (Debug or Release) DLL version of the CRT, they will share one global CRT instance. This is because they both contain just a reference to the DLL and a DLL is always loaded only once into the process address space. Thus you can freely exchange CRT resources (memory blocks, FILE*, etc.) between your DLL and your .exe.
Note that this problem does not occur if you are using Win32 API resources. Because the Win32 API libraries are always DLLs you never run into the static linkage problem.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
Thanks guys.
Wow. This is an interesting problem and is something I never expected.
First, why is it a bad design to return data back from a DLL? Is it a bad design to return an STL data structure back from a DLL?
What if you were to compile the DLL and EXE in one project instead of two separate projects?
I compiled the DLL in a separate project. Here is how I did it.
- project1 is DLL only
- project2 is EXE statically importing DLL
I thought it is okay to compile a dll separately and then using .dll, .lib, and .h files in any other project that will statically import the dll. Furthermore, you can use the .dll file in any project that dynamically imports the dll.
If the message I receive is what I believe it is, you need to compile all DLL and EXE in one project if and only if you want to statically import DLLs.
niyaw of GameDev mentioned something about setting the compiler for *multithreaded DLL runtime*. What is that about?
Kuphryn
|
|
|
|
|
Okay. I believe I see the problem. The problem has to do with setting the compiler (Visual C++ .NET) to compile both the DLL project and EXE project (both debug and release versions) to "Multi-threaded DLL /MD."
The solution above is from niyaw of GameDev. Everything works, except for one problem. I am using MFC doc/view as program core. I have set the compiler to "Use MFC in a Static Library." I believe when you set to that option, the compiler automatically changes "Multi-threaded DLL /MD" to "Multi-threaded /MT."
So the bottomline is that the original problem has to do with multithreaded DLL setting and can be fixed. However, if I fix that problem, I cannot use MFC via Static Library. That is okay too, but then I would have to gather all MFC dll into one zip file before releases the program. Some people do not have MFC DLLs.
Kuphryn
|
|
|
|
|
Hi,
I did see a program from MSDN sample Send Email with a Notepad npp.prj! After the user selecting Send option, the program opens an OutLook Express with an attached Notepad file (launch at the beginning)!
But what I need is a bit different! I would like to open the same OutLook Express but with a destinated user Email address (ie: thanhchau@videotron.ca) and with an existed attachment that I will insert at Run time (ie: c:\sample.txt)... without using any NotePad or any editor!
Any one has done it before? I will appreciate any codes or guidelines here!
Thanks & regards,
|
|
|
|
|
Oh, are you ever in Luck! Click here to download PJ Naughter's CMapi class. It will do all you need.
Note it is also here on CP, but it is an earlier version, so download the one at the link above.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
Hi Shog,
I did download and try, but I got stuck with the the project and have 11 errors after copiling:
One of them is: MailDlg.cpp(154) : error C2039: 'AddMultipleRecipients' : is not a member of 'CMapiMessage'
C:\SmartEmail\CMapi.h(24) : see declaration of 'CMapiMessage'
I did look into the class itself & really see that it does not have the member of the error C2039!
Did you try it before?
Thank for help, might be you know this problem & help me again?
ThanhChau
|
|
|
|
|
Hmm, that's odd. I've only used the version posted here, not the one on PJ's website; i just saw there was a later version there. But, you might as well try the version here:
http://www.codeproject.com/internet/cmapi.asp
If this one works, you should probably drop Mr Naughter a line to let him know about the problem with the newer version.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
Try using ShellExecute() to open this "document": "mailto:thanhchau@videotron.ca" .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi Ravi,
I did try as you suggest after the "mailto:thanhchau@videotron.ca". The problem it appear outside of the OutLook Express.
Might be I did not understand what you suggested: If some how it appear inside the contents of OutLook Express ---> OK! Would you please more specify on this!
Thanks a lot for help!
ThanhChau
|
|
|
|
|
Hmm, the ShellExecute() call should cause your default mailer to open. If it's not OE, then are you saying that you want OE specifically to deliver the message? Sorry if I put you on the wrong track!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|