c 语言用win32sdk方式如何创建一个没有标题栏和边框的窗口

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c 语言用win32sdk方式如何创建一个没有标题栏和边框的窗口相关的知识,希望对你有一定的参考价值。

参考技术A 窗口风格参数 只用一个 WS_POPUP 应该就可以了本回答被提问者和网友采纳 参考技术B 查win32api 这个创建窗口的过程有好几步骤的

栈的两种实现方式(C语言)

栈的两种实现方式

通常情况下,栈的实现方式有两种,一种方法是使用指针,而另一种方法则是使用数组。但是在调用程序时,我们没有必要知道具体使用了哪种方法。

1、链式栈

这里,我们需要用单链表的知识去实现一个栈。具体步骤如下:

1.1创建链表节点

struct Node
{
	int Data;
	struct Node* Next;
};

1.2初始化链表函数

struct Node* CreateNode(int data)
{
	struct Node* NewNode = (struct Node*)malloc(sizeof(struct Node));
	NewNode->Data = data;
	NewNode->Next = NULL;
	return NewNode;
}

1.3创建栈

struct Stack
{
	int StackSize;
	struct Node* pStackTop;
};

1.4初始化栈的函数

struct Stack* CreateStack()
{
	struct Stack* NewStack = (struct Stack*)malloc(sizeof(struct Stack));
	NewStack->StackSize = 0;
	NewStack->pStackTop = NULL;
	return NewStack;
}

1.5Push和POP操作

个人觉得这两个函数可以有很多种写法,下面就介绍我自己写的一种~

void Push_Back_Stack(struct Stack* stack, int data)
{
	struct Node* NewNode = CreateNode(data);
	NewNode->Next = stack->pStackTop;
	stack->pStackTop = NewNode;
	stack->StackSize++;
}

void Pop_Back_Stack(struct Stack* stack)
{
	if (stack->StackSize == 0)
	{
		printf("栈为空,删除失败!\\n");
		return;
	}
	struct Node* pNode = stack->pStackTop->Next;
	free(stack->pStackTop);
	stack->pStackTop = pNode;
	stack->StackSize--;
}

还有一个,就是获取栈顶元素,这个很简单,我就懒得去写了emm…
链式栈大概就是这样,当然,在一些书本上有非常完善的写法,但是,也让我看得头皮发麻…

#ifnef _Stack_h_
struct Node;
typedef struct Node *PtrToNode;
typedef PtrToNode Stack;

int IsEmpty(Stack S);
void DisposeStack(Stack S);
void MakeEmpty(Stack S);
void Push(ElementType X,Stack S);
ElementType Top(Stack S);
void Pop(Stack S);

#endif /* _Stack_h */

struct Node
{
	ElementType Element;
	PtrToNode Next;
};

2、数组栈

数组栈比链式栈还要容易一些,并且可以避免实用指针(指针当然是能不用就不用了哈哈),但其缺点是它的大小是固定的,我们必须提前声明它的长度,而且无法改变(至少C语言基础篇里面没有这种功能)。
就用一个转化二进制的案例来展现吧:

2.1.1

int stack[10];
int stackTop = -1;
int num = 111 * 2;
printf("%d的二进制值为:", num);
while (num /= 2)
	stack[++stackTop] = num % 2;
while (stackTop-- != -1)
	printf("%d", stack[stackTop + 1]);
printf("\\n");

这段代码看起来是不是很诡异?不过还有一种数组栈的实现方式,可能看上去要好一些。

2.2.1 创建栈####

struct Stack
{
	int* StackMemory;
	int stackTop;
};

2.2.2初始化栈函数

struct Stack* CreateStack()
{
	struct Stack* NewStack = (struct Stack*)malloc(sizeof(struct Stack));
	NewStack->StackMemory = (int*)malloc(sizeof(int) * MAX);
	NewStack->stackTop = -1;
}

2.2.3push和pop操作

void Push_Back(struct Stack* stack, int n)
{
	if (stack->stackTop + 1 == MAX)
	{
		printf("栈已满,无法入栈\\n");
		return;
	}
	stack->StackMemory[++(stack->stackTop)] = n;
	printf("%d\\n", stack->stackTop);
}

int popStack(struct Stack* stack)
{
	if (stack->stackTop == -1)
	{
		printf("栈为空,无法退栈\\n");
		return;
	}
	int data = stack->StackMemory[stack->stackTop];
	stack->StackMemory[stack->stackTop] = 0;
	stack->stackTop--;
	return data;
}

这样虽然繁琐,但个人觉得这样更能体现数组栈。

以上是关于c 语言用win32sdk方式如何创建一个没有标题栏和边框的窗口的主要内容,如果未能解决你的问题,请参考以下文章

创建可在另一种语言上调用的 win32api(dll) [关闭]

用VS创建一个win32窗口,编译运行都可以,但那个窗口没有显示出来

win32程序创建线程用c语言库的_beginthread还是API的CreateThread?哪种用的多?

windows 创建快捷方式 win32API C语言

windows 创建快捷方式 win32API C语言

c语言 win32api 创建一个按钮,点击按钮后,按钮消失?