|
I'm new in the programming for Windows (but have few year expirence in programming for Unix).
My app will be work with unlimit number of grouped object. Each object consists of predefined number of text fields and unlimited number of accociated binary objects.
The database will support only one client/database builder.
I can build the db by simply creating directory structure but is there any solution to do this by using Access datafiles of something like that?
|
|
|
|
|
Have a look a this link [^].
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Mastering MFC Development Using Microsoft Visual C++ 6
Chapter 7: Using OLE DB Templates for Data Access
Chapter 8: Creating ADO Database Applications
M$PRESS
|
|
|
|
|
Hello all,
I'm writing a quick/dirty class wrapper for the Win32 MDI API. After developing most of the code, I came across this article by Jason Henderson, who has done the same thing, and found my code was about 99% identical . I am using the same strategy of calling CreateWindow and passing 'this' in lParam, then using SetWindowLong/GetWindowLong in WndProc to store/retrieve the class pointer in the HWND.
My code successfully creates a Frame, Client, and Child windows. However, for some reason when creating the Child window, the class pointer in lParam gets corrupted when the WndProc tries to retreive it from the CREATESTRUCT. In the debugger lParam is 0x00891030, then in WndProc it retrieves 0x0012fcfc every time.
How can this happen? I'm creating the Frame and Child WndProc's the exact same way, so why would the Child have this problem?
Thanks for reading.
|
|
|
|
|
For the archives, I was able to work around this problem by using the WM_MDICHILD message instead of CreateMDIWindow or CreateWindowEx. I can't explain why it works, but it now works like a charm.
If anyone can shed light, I would appreciate it. One day I may need to use CreateWindowEx because you can run multithreaded MDI children, but you can't with WM_MDICHILD.
|
|
|
|
|
Hello, I'm just a little curious. When i browse through some librarys I sometimes see functions delclared this way:
<returntype> SomeFunc(<arg list>) = 0;
Now my question is: What does the = 0; mean and what is its purpuse?
thanks in advance.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
If it's in a class, you might be referring to a pure virtual declaration
class SomeClass
{
virtual void someFunc() = 0;
};
Which means that there is no body of the function supplied, or in other words, that you need to derive from that class, adding the required functionality.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Thanks, now I can go to sleep without wondering what it might be...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Hi guys (sorry for the last incomplete message).
Do you have a fast algorithm to generate the permutations of a string.
Ex:
4-3-2
4-3-2 4-2-3 3-4-2 3-2-4 2-4-3 2-3-4
And another one that ignore repeated chars?
Ex
4-1-1
4-1-1 1-4-1 1-1-4
Actually 4-1-1 had to appear twice but I only want that appears one.
Best Regards
Dr.Pi
|
|
|
|
|
I don't know about the avioding repetitions part, but here is what I would do:
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
typedef void (*FOUND)(char*);
void PermRec(char *str, char *buf, FOUND callback)
{
int i, n;
char *buf2;
if (*str == '\0')
{
(*callback)(buf);
return;
}
n = strlen(buf);
buf2 = malloc(n + 2);
for (i = 0; i <= n; i++)
{
if (i != 0) memcpy(buf2, buf, i);
buf2[i] = *str;
if (i != n) memcpy(buf2 + i + 1, buf + i, n - i);
PermRec(str + 1, buf2, callback);
}
free(buf2);
}
void EnumPermutations(char *str, FOUND callback)
{
PermRec(str, "", callback);
}
void foundone(char *str)
{
printf("%s\n", str);
}
int main (int argn, char **argv)
{
if (argn <= 1)
{
printf ("Usage:\n %s <string>\neg:\n %s 123", argv[0], argv[0]);
return 1;
}
EnumPermutations(argv[1], foundone);
} eg if called with "123", first it places the 1:
1
then it places the 2 in each of the 2 spots:
21 or 12
then it places the 3 in each of the 3 spots:
321 or 231 or 213, 312 or 132 or 123
what I would probably then do is make it remember in foundone() which permutations it had already recieved, and ignore them if it gets them again.
BTW: there is a "modify" button for when you mess up your post
=====
Phlip
Always proofread carefully to see if you any words out
|
|
|
|
|
Thanks
I'll try it
Best Regards
Dr.Pi
|
|
|
|
|
try this (not for repeated chars):
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
void swap(char* pc1,char* pc2)
{
char ch;
ch = *pc1;
*pc1 = *pc2;
*pc2 = ch;
}
void perm (char* s,int pos)
{
if (pos == (int)strlen(s))
{
printf("%s\n",s);
return;
}
for (int i=pos;i < (int)strlen(s);i++)
{
swap(s+pos,s+i);
perm(s,pos+1);
swap(s+pos,s+i);
}
}
int main(int argc, char* argv[])
{
char s[] = "abc";
perm(s,0);
return 0;
}
|
|
|
|
|
|
How can I send extended chars (c>=128) using SendInput()?
I have tried sending eg {PRESS ALT}{NUM 0}{NUM 1}{NUM 7}{NUM 5}{RELEASE ALT} to type '¯' - this is you you type it on the keyboard - but it had no effect.
any ideas?
thanks in advance
=====
Phlip
Always proofread carefully to see if you any words out
|
|
|
|
|
Hello, everyone!
Suppose in multi-process environment, one process want to read
characters from stdin, and the other process has nothing to do
with stdin. And there are no synchronize control between the two
process.
And I think it has chances that the characters can be read by the
second process even if the second process has nothing to do with
stdin, and the first process will miss some characters.
Am I correct?
I have seen one solution from others. They use "close (stdin)" in
the socond process. Is this a good solution?
Thanks in advance,
George
|
|
|
|
|
Every process will have its own stdin, so theres no need to worry about synchronisation (unless you are talking about parent/child processes?). Its only when youve got multiple threads in one process trying to use stdin that you will need to think about synchronisation, and then a simple mutex should do the job.
|
|
|
|
|
Thanks, Johnny buddy!
I am talking about parent/child processes. I am currently dealing with
a cross-platform IPC library which acts like "fork" in Linux.
Can you help with my original question?
regards,
George
|
|
|
|
|
Win32 has no parent/child relationship between processes. Johnny's answer is just as valid. Each process has its own stdin.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks, Ryan buddy!
What about under Linux environment? Suppose a parent process "fork" a child process, and the child process share the stdin fd. So I think if they all
read from stdin, they need to have some methods of synchronization to ensure
the integrity of user input data.
Am I correct?
regards,
George
|
|
|
|
|
Whichever process is running in the foreground will have the user input. The others are detached from stdin and will not get any input.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Well, suppose process 1 gets running foreground and the user wants to input
"Hello World". After typing "Hello", process 2 gets running foreground and gets input " World".
So in this instance, input is error.
Am I correct?
George
|
|
|
|
|
Under linux, only the user can change the foreground process, unless the foreground process terminates. However, a foreground process cannot terminate while it is reading input, unless the user logs on from another terminal and kills it remotely (either that or the process traps a signal and kills itself). The process won't even get any input until the user presses the enter key, in which case all the input will get sent to the foreground process at that time.
So no, what you're describing cannot happen.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks, Ryan buddy!
I have made an example to show the stdin are shared between parent and child process. And even if a process is waiting for input, it can still become inactive.
Sample code:
--------
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
main()
{
pid_t pid;
int rv;
switch(pid=fork()) {
case -1:
perror("fork"); /* something went wrong */
exit(1); /* parent exits */
case 0:
while (1)
{
printf("In child process \n");
scanf(" %d", &rv);
printf("Child read: %d \n", rv);
}
exit(rv);
default:
while (1)
{
printf("In parent process \n");
scanf(" %d", &rv);
printf("Parent read: %d \n", rv);
}
wait(&rv);
printf("PARENT: My child's exit status is: %d\n", WEXITSTATUS(rv));
printf("PARENT: I'm outta here!\n");
}
}
--------
Output from my Linux box,
--------
[root@localhost ml]# ./MultiProcessStdin
In parent process
In child process
10
Child read: 10
In child process
20
Parent read: 20
In parent process
30
Child read: 30
In child process
40
Parent read: 40
In parent process
--------
So, you are wrong.
George
|
|
|
|
|
George2 wrote:
So, you are wrong.
Yes and no
Which process gets the input will depend on which one executes the scanf() call first. Only one process can access stdin at any time - the kernel will prevent others from reading from it. So yes, processes can attempt to access stdin at the same time, and whichever one is currently waiting for input will get the input.
However, I said that the process will get the input when the user presses enter. If you put all the numbers on one line, then one process will get them all.
I hope this is all correct. I think it is, but I haven't done linux programming for about a year...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks, Ryan buddy!
I think at this point, you are correct.
Quote:
--------
If you put all the numbers on one line, then one process will get them all.
--------
I have made another sample to prove this idea,
Sample code:
--------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys types.h="">
#include <sys wait.h="">
main()
{
pid_t pid;
int rv;
char buf [20];
memset (buf, 0, 20);
switch(pid=fork()) {
case -1:
perror("fork"); /* something went wrong */
exit(1); /* parent exits */
case 0:
while (1)
{
printf("In child process \n");
scanf(" %s", buf);
printf("Child read: %s \n", buf);
}
exit(rv);
default:
while (1)
{
printf("In parent process \n");
scanf(" %s", buf);
printf("Parent read: %s \n", buf);
}
wait(&rv);
printf("PARENT: My child's exit status is: %d\n", WEXITSTATUS(rv));
printf("PARENT: I'm outta here!\n");
}
}
--------
Output:
--------
[root@localhost ml]# ./MultiProcessStdin
In parent process
In child process
abc
Child read: abc
In child process
abnsa
Parent read: abnsa
In parent process
--------
Am I correct?
regards,
George
|
|
|
|