|
I think VC IDE framework is pretty cool. I want to implement my project appearance like it. Dockable project window, debug output and so on... Is there anybody give me clue how to implement it?
Richard Luo
|
|
|
|
|
|
Try using the CSplitterWnd class
that will help u in developing such a project.
But u dont get anything readymade , u need to
put up ur own code for ur ideas.
Vikas Amin
Embin Technology
Bombay
|
|
|
|
|
I have an MDI application which works with a database. A new CDialog was added to the MDI, and now i want to make some calls to the database. There is a Callback mechanism already implemented in the app, which i will be using for recieving values back from database. I prefer to start a new thread, which will be independent of the main GUI thread to pass on values to the database. Can anyone tell me how can i create a new thread inside my CDialog to make calls to database?
Another thing i wanted to know is, how to use WaitForSingleObject, i would like to wait in the thread till i get the response back from database and then to update it in the CDialog. I would appreciate if you could tell me how to use WaitForSingleObject?
|
|
|
|
|
First you would need to find out if the database is actually thread safe. Unless there is a compelling reason to use multiple threads I suggest you don't: writing multithreaded applications is hard. Debugging buggy multithreaded applications can be a nightmare.
Steve
|
|
|
|
|
Hihi,
I'm trying to use CreateFile to check whether or not a certain device is connected to the serial port. Here's the code:
HANDLE testport = CreateFile("\\\\.\\COM1",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL );
It's failing, and GetLastError is returning 87, ERROR_INVALID_PARAMETER.
This portion of the code is for WinCE, for WinXP I use "COM1:" instead of "\\\\.\\COM1"
Anyone know what could be wrong?
The device is connected to the COM port, so the result should not be a failure.
Kelly Ryan
|
|
|
|
|
The Windows CE documentation for CreateFile in MSDN says that for a com port, you must include the colon after the name, and makes no mention of the need for the \\.\ beforehand. I'm no CE expert, but why are you using different filenames for CE and XP?
|
|
|
|
|
The code is pulled from another project we have here which deals with both WinCE and XP and those are the names it uses. I started out with both the same and after I was having problems, took a look at that code and decided to try it instead since it seems to work in the other project. Unfortunately it doesn't work either.
Kelly Ryan
|
|
|
|
|
With a bunch more messing around, now it produces error 2, ERROR_FILE_NOT_FOUND instead of error 87. Does anyone have any ideas??
Kelly Ryan
|
|
|
|
|
Finally got it; I had to print the com port name into a TCHAR before I passed it to CreateFile. Bleeh...
Kelly Ryan
|
|
|
|
|
Hi experts,
How can I read the file header to determine the type of the file?
Let say, the pdf ile will have %pdf in the header. So after reading the header, I can decide which application to use to open that file.
|
|
|
|
|
To do this effectively would be hard. The FindMimeFromData API may be of interest to you however.
Steve
|
|
|
|
|
i know it would be hard.
but i already have the list to of file extension and its magic code to identified which type of file.
just need to know how to read the file header. I remember I did read file header in college. but i just dont' really sure if I had used reading file in binary fomrat for header.. couldnt' do it anymore. If any of you know how to read the file header, please help me out.
Thanks
|
|
|
|
|
CreateFile with OPEN_EXISTING followed by a ReadFile of a certian number of bytes would do the trick.
|
|
|
|
|
Hi,
I have a dialog with a colored background (no bitmap) with the controls being transparent. Now I can get the edit boxes to redraw correctly, BUT I cannot get the sliders to redraw correctly.
I have seen custom CSliderCtrl classes that may do this but I am hoping that I can fix the problem with just a small amount of code.
Thanks in advance for any help!
|
|
|
|
|
Jerry Ott III wrote: I have a dialog with a colored background (no bitmap)
Where are you doing the coloring?
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Below is what I have for the OnCtrlColor and the OnEraseBkgnd functions that are in the class with the slider.
I'm still very new to the MFC stuff so basically just found parts of code other people have shown and have used that with hopes of actually learning it so I can make my own things.
Right now I just have the sliders not being transparent or anything so that they redraw correctly.
HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr;
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(255,255,255));
hbr = (HBRUSH)GetStockObject( NULL_BRUSH );
return hbr;
}
BOOL OnEraseBkgnd(CDC* pDC)
{
CPen myPen[64] ;
int i ;
CRect rect ;
for (i = 0 ; i <= 60 ; i++)
myPen[i].CreatePen(PS_SOLID, 1, RGB (0,0,(i * 4)));
CPen *oldPen = pDC->SelectObject(&myPen[0]) ;
GetClientRect(&rect);
for(i = 0 ; i <= rect.bottom;)
{
pDC->MoveTo(0, i);
pDC->LineTo(rect.right, i);
i++;
pDC->SelectObject (&myPen[i * 64 / rect.bottom]);
}
pDC->SelectObject(oldPen) ;
return TRUE ;
}
|
|
|
|
|
Hi, God Morning/afternoon,
May I know how to work with c files on a visual C++ 6.0 IDE?
Some people say it is easy, howver I am encountering a lot of problems.
examples simple. project.
the c file looks like:
/* ------------- */
/* mon_include.c */
/* ------------- */
#include <stdio.h>
main()
{
#include "mon_include.h"
i = 10 ;
j = 20 ;
k = i+j ;
printf("k = %d\n",k);
}
and the *.h file
/* ------------- */
/* mon_include.h */
/* ------------- */
int i,j ;
int k ;
/* ------------- */
Thanks a lot,
I work on Visual C++ 6.0 introductory edition.
T.
|
|
|
|
|
I think this is what you want to do?
{
FILE *flog;
i = 10 ;
j = 20 ;
k = i+j ;
flog = fopen("c:\\directory\\test.txt", "w");
fprintf( flog,"%s, %d\n","k=",k );
fclose ( flog );
}
If you look in the directory called "directory" you should find your file (test.txt).
|
|
|
|
|
I think this is what you want to do?
Tombo
Would you please tell how that guy can use this, please check before you post something .
Regards,
FarPointer
|
|
|
|
|
thierrypp wrote: ...howver I am encountering a lot of problems.
And what would those problems be?
thierrypp wrote: #include "mon_include.h"
Did you mean to have this statement inside of main() ?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
thank you, but really, more generally, can a common C programme be compiled on a Visual C++ 6.0 compiler?
and how?
Regards,
T.
|
|
|
|
|
thierrypp wrote: can a common C programme be compiled on a Visual C++ 6.0 compiler?
Certainly. Why wouldn't it?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
I have a set of C files which can be compiled on a C-compiler, but not at all on Visual C++6.0.
Maybe you could tell me the right procedure to do it.........
Or I can send you examples?
Thank you,
T.
|
|
|
|
|
for example:
/* ---------- */
/* premier2.c */
/* ---------- */
#include <stdio.h>
#include <math.h>
main()
{
int nb, diviseur1, diviseur2,reste ;
int trouve,i ,racinecar,limite ;
int nb_iterations=1;
printf("Entrez un Nombre :");
scanf("%d",&nb);
/* partie entiere de la racine carre+1 */
limite=sqrt(nb)+1;
trouve=0 ;
if (nb != 2) /* 2 est premier */
{
/* on retire le cas des nombres pairs */
reste=nb%2 ;
if (reste == 0)
{
trouve=1 ;
/* on memorise les diviseurs */
diviseur1=2 ;
diviseur2=nb/2 ;
}
else
{
/* teste tous les diviseurs impairs */
i=3;
while ( (! trouve) && (i<=limite) )
{
nb_iterations++;
reste= nb%i ;
if (reste == 0)
{
trouve=1 ;
/* on memorise les diviseurs */
diviseur1=i ;
diviseur2=nb/i ;
}
i+=2 ;
}
}
}
if (trouve)
{
printf("%d n'est pas premier !\n",nb);
printf("il est divisible par %d et %d\n",diviseur1,diviseur2);
}
else
{
printf("%d est un nombre PREMIER !\n",nb);
}
printf("RŽsultat obtenu en %d itŽrations\n",nb_iterations);
}
result:
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/premier2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
premier2.exe - 2 error(s), 0 warning(s)
|
|
|
|