|
Thanks Avi,
so the DLL search order is defined , but what about the dLL .lib?
I am putting it in Project Settings Link with \Debug subdirectory.
I assume I need to change it in release.
I recollect someone using preprocessor directive to link the library, but forgot the details.
Right now I discovered that building DLL via plain win32 dll wizard does not recognize MFC stuff , even if I change it later.
But using MFC dll wizard gives me a linker error!
Time to quit!( at least for a while!)
BTW I did made headway with COM programming - as suspected the key is in using OVERLAPPED structure. Right now my whole program is "broken" because I am trying to rebuild it with DLL's.
Vaclav
|
|
|
|
|
I see no reason to split up a project unless you really need to reuse logic elsewhere. Adding a DLL or static library adds complexity for no reason.
How many files are we talking about? I've had projects with dozens of files. Naming them properly seems the best approach, though you could organize them into folders if that helped.
|
|
|
|
|
Let me first state that I was not looking for discussion why to do this. I do get flustered when people change the subject of thread. But I mean no offense.
First – my projects are build to have parts reusable. My favorite place is Gallery.
This particular project is essentially user interface to ham radio.
The essential part is communication using serial port – hence a serial port DLL would be nice.
Next I need detailed trace of how this communication is accomplished – a log DLL is in order.
The program will eventually do Morse code , digital (packet) communication, etc.
My ultimate goal is slow scan television – both video and audio access to PC. .
As you can see, these piece parts do essentially same task – send data, make sure it gets there and then reverse the process.
So modularity is natural.
As far as naming conventions – I do not care much about that. For example – when you use MFC Property Sheets MFC names them for you ( 10 plus files for 10 pages) , not to intuitive but easy.
As far as using folders in VC 6.0 = absolutely out of question. Over the years I have been using VC++ I have lost the folders so many times , I do not care to count and waste my time.
Enough soap box.
Thanks for you input.
Vaclav
|
|
|
|
|
p1++ = map[((*p++ << 5) & 0x3) | ((*p >> 3) & 0x5)]; <-error, "p++" inoperative
p1++ = map[((*p++ << 7) & 0x5); <- ok, "p++"
but vc compiler do it like this
p1++ = map[((*p << 5) & 0x3) | ((*p >> 3) & 0x5)];
p++;
p1++ = map[((*p << 7) & 0x5);
p++;
why not
value = map[((*p << 5) & 0x3);
p++;
value |= ((*p >> 3) & 0x5)];
p1++ = value;
p1++ = map[((*p << 7) & 0x5);
p++;
how to fix it only use "++"modified on Sunday, March 7, 2010 6:33 AM
|
|
|
|
|
If you use a pointer (or indeed a value) in an expression, and the expression modifies that value (as you do above with p++ ) then the compiler will not guarantee that the new and old values are used in the order that you expect. This is due to compiler optimisation and is spelled out in the C++ language specification. In the line
p1++ = map[((*p++ << 5) & 0x3) | ((*p >> 3) & 0x5)];
if p contains 0x100 before this line is executed, then it will contain 0x101 afterwards. However there is no guarantee that it will contain 0x101 in the right half of the OR expression. You should rewrite your expressions to ensure no side effects.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
I'd code-review you back to kindergarden if I was presented code like that. Watched code never compiles.
|
|
|
|
|
So now im focusing on learning typedef, I read off functionX and made up my own piece of code:
#include "stdafx.h"
#include <string>
#include <conio.h>
#include <iostream>
using namespace std;
typedef string ThreeStrings[3];
int _tmain(int argc, _TCHAR* argv[])
{
ThreeStrings islands = { "Fiji" , "Caribbean" , "Bora Bora" };
for (int i=0 ; i < sizeof(islands) / sizeof(string); i++)
cout << "\n\t" << islands[i] << "\n" << endl;
_getch();
return 0;
}
So as you can see my typedef is declared Globally and you can also see that my alias is 'islands', I know I havent declared in my main or globally as 'int char or string' does that make it volatile or can only be used multiple times or changed in main?
Can I use 'islands' globally through other functions or only in main, and do I have to call it through other functions like
int function(typedef ThreeStrings islands)
{
.body..
}
|
|
|
|
|
I'm not exactly sure what you're asking. ThreeStrings can be used anywhere its definition is "visible": in this case anywhere in the file "Typedef.cpp" after "typedef string ThreeStrings[3]; ". Also note that's it's simply a typedef for an array of three std::string s so anywhere you see this:
ThreeStrings xxx;
it is equivalent to this:
std::string xxx[3];
islands is a local variable. It is mutable (its contents can be changed). Normally it is only visible within the _tmain function. It can be made available to functions called by _tmain (and functions called by functions called by _tmain , and so on) by passing a pointer or reference to it (or by making a pointer or reference to it accessible by some other means). For example:
void function(ThreeStrings &i)
{
i[0] = "I changed it!";
}
int _tmain(int argc, _TCHAR* argv[])
{
ThreeStrings islands = { "Fiji" , "Caribbean" , "Bora Bora" };
function(islands);
for (int i=0 ; i < sizeof(islands) / sizeof(string); i++)
cout << "\n\t" << islands[i] << "\n" << endl;
_getch();
return 0;
} Steve
|
|
|
|
|
Ok so if their equivalent what would be the purpose of using typedef, why not just use std:string? I need a bit more detail if that is ok, I tryed functionX and Cplusplus but still not seeing the differences.
|
|
|
|
|
A couple of reasons to use typedef is to make your code clearer to some poor human who has to read it.
If you're using a particular declaration a great number of places in your code, it MAY make your code clear if you make the intended use of those variables or funcitions obvious using typedefs.
Another is laziness. You often see typedefs where a particular declaration is very long and verbose, such as template classes and functions. It saves a lot of typing, retyping, and compiler errors to correct. And in the process, it may make your code more readable as well.You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Hi,
I am trying to format the contents of a RichEdit Control I would like to some how ensure the Begining of a new line
I realize I am dealing with pixels and not text characters and thus the length of a Line will vary if on line has more wide character pixels then the next
I plan to populate the RichEdit using streamin
I can the used the FindWordBreak method the determine where after populating the RichEdit The RichEdidt has decided to break the line
I can append the end of a line with say 5 blank characters
If a 1 line has more wide pixel character pixels the previous I can lets say remove 2 of the trailing blanks to force line a break to where I want
Though I am not quite sure how to remove charcters from the RichEdit Object
My question then is does what I am trying to do make sense
and if so is there a way to remove characters from the RichEdit before it is displayed
Thankx
|
|
|
|
|
ForNow wrote: to some how ensure the Begining of a new line
Please provide an example of what you are trying to do.
If you are streaming into the RichEdit Object, and you want to manipulate where the lines break, you will have to manipulate the stream before letting the RichEdit handle it.
|
|
|
|
|
Hi,
Please see this part of my code below for the message box that appears when the user presses the exit button, but if the user presses no on the message box the application still exit's. I have tried a good couple of times to fix it but it will not work. Please help.
case WM_KEYDOWN: <br />
if (wParam == VK_ESCAPE)<br />
MessageBox(NULL, L"Are you sure you want to exit?", L"My Project", MB_YESNO |MB_ICONQUESTION);<br />
DestroyWindow(hWnd);<br />
return 0;<br />
Thank you.Andrew McIntyre
|
|
|
|
|
You need to check the return value from MessageBox and execute DestroyWindow conditionally on the user response:
case WM_KEYDOWN:
if (wParam == VK_ESCAPE)
{
if (MessageBox(NULL, L"Are you sure you want to exit?", L"My Project", MB_YESNO |MB_ICONQUESTION) == IDYES)
DestroyWindow(hWnd);
}
return 0; L u n a t i c F r i n g e
|
|
|
|
|
Thank you so much, the code works fantastically. Andrew McIntyre
|
|
|
|
|
IMO, with proper formatting, you would have noticed that right away.
PS: please use PRE tags (not CODE tags) for showing code snippets here.
|
|
|
|
|
I knew it was something simple, but I need to spot these things better next time. Andrew McIntyre
|
|
|
|
|
Luc Pattyn wrote: IMO, with proper formatting, you would have noticed that right away.
PS: please use PRE tags (not CODE tags) for showing code snippets here.
But that's what his code actually looks like. You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
I will remember to use PRE tags whenever I have snippets, sorry for using the wrong tags as I am not use to them yet. Andrew McIntyre
|
|
|
|
|
I don't know if you can help me with this but I want my application to check if the user has an internet connection and if they don't it will display a message box. How would I go about this? Andrew McIntyre
|
|
|
|
|
As you've been told countless times on this site, you need to get a few books, study the hell out of them and learn the basics, and then you can ask reasonable questions. Besides, I thought your employees were going to handle all the heavy lifting and you were just playing with this a little to see what slumming with the riff-raff felt like? You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
I take it there's some history here I'm unaware of. L u n a t i c F r i n g e
|
|
|
|
|
LunaticFringe wrote: I take it there's some history here I'm unaware of.
Check MrM's previous posts, I have tried quite hard to teach him what development is about, but with little success. Perhaps someone else can engage with him sufficiently to get the message across.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Richard's reply is dead on. This thread[^] is a particularly good example. He also periodically tries to troll for "exployees" for his "company". The theme is something like I'll glady pay you when the game makes big bucks as long as you do ALL the work today. You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Thanks for the link. A little comedy on an otherwise quiet Sunday afternoon. The guy can't use an 'if' statement, but...
'Richard maybe you shouldn't be that cheeky as I don't think you know how powerful and well respectedand I am. I have close contacts with the BBC and serveral companies who are interested in sponsorship and advertising opportunities within my 3D virtaul world.' - MrMcIntyre
L u n a t i c F r i n g e
|
|
|
|