首页 \ 问答 \ Win32 CreateWindow()调用在子线程中挂起?(Win32 CreateWindow() call hangs in child thread?)

Win32 CreateWindow()调用在子线程中挂起?(Win32 CreateWindow() call hangs in child thread?)

我正在研究OpenGL的可移植性层(抽象出Linux和Windows的glX和wgl)...总之,它有一个创建Window的方法...如果你没有传入父级,你会得到一个带有框架的真实窗口......如果您通过父母,您将获得一个无边界,无框架的窗口......

这工作正常,只要我在1个线程上完成所有操作...只要另一个线程尝试创建子窗口,应用程序就会在win32调用“CreateWindow()”中死锁。 有任何想法吗?


I'm working on a portability layer for OpenGL (abstracts the glX and wgl stuff for Linux and Windows)... Anyhow, it has a method for creating a Window... If you don't pass in a parent, you get a real window with a frame... If you pass in a parent, you get a borderless, frameless window...

This works fine, as long as I do it all on 1 thread... As soon as another thread tries to create a child window, the app deadlocks in the win32 call "CreateWindow()". Any ideas?


原文:https://stackoverflow.com/questions/1759093
更新时间:2022-04-29 10:04

最满意答案

@DamirDžilić - 没有任何真实的代码可以发表评论,我们只能给出概念建议。 你将不得不将每一手牌与所有可能的扑克手牌进行比较,从最高等级的手牌到一对牌手。

我个人建议每张卡都是一个对象:

var card = {suit: "S", value: 9};

然后,一只手将是一组卡片对象。

然后,您可以分别查看套装和卡片价值。 如果卡值在2到14之间并且您转换为J,Q,K,A仅用于显示,则会更容易。

然后,每个可能的扑克手(一对,三种,四种,同花顺,直线等等)将按照他们在扑克中的价值得分(对= 1,两对= 2,三对)一种= 3,直= 4,冲洗= 5,满屋= 6,同花顺= 7,四种= 8,同花= 9)。

然后,我建议你给每种类型的手一个得分,其中包括10000 *手牌值+ 100 *顶级卡牌+踢球者值。 因此,一对带有K踢球的8对值得:

(2*10000) + (8*100) + 13 = 20,813

并且,带有A踢球者的三个2将是:

(3*10000) + (2*100) + 14 = 30,214

使用这种类型的得分系统,手牌值总是占主导地位,然后是手牌得分的顶级牌(例如3个女王击败3个等),然后踢球者打破任何关系。

你可以自己编写代码来确定你拥有什么样的牌,但基本上你必须检查直道,冲洗以及你拥有多少普通牌。 我可能会首先寻找配对,只有在没有配对的情况下才能寻找直道或冲洗,并且我会找到一个能够寻找每个配对的功能。


@DamirDžilić - without any real code to comment on, we can only give conceptual advice. You're going to have to just compare each hand against all possible poker hands, starting with the highest rated hand down to a single pair.

I'd personally suggest that each card be an object:

var card = {suit: "S", value: 9};

Then, a hand would be an array of card objects.

You can then look at suit and card value separately. It would be easier if card values where 2 through 14 and you convert to J, Q, K, A only for display.

Then, each possible poker hand (pair, three of a kind, four of a kind, flush, straight, etc...) would get a score in order of their value in poker (pair = 1, two pair = 2, three of a kind = 3, straight = 4, flush = 5, full house = 6, straight flush = 7, four of a kind = 8, straight flush = 9).

Then, I'd suggest you give each type of hand a score which consist of 10000*hand value + 100*top card in hand + value of kicker. So, a pair of 8's with a K kicker would be worth:

(2*10000) + (8*100) + 13 = 20,813

And, three 2's with an A kicker would be:

(3*10000) + (2*100) + 14 = 30,214

With this type of scoring system, the hand value always dominates, then the top card that's part of the scoring piece of the hand (e.g. 3 queens beats 3 eights), then the kicker breaks any ties.

It would be up to you to write the code for figuring out what kind of hand you have, but basically you have to examine for straights, flushes and how many common cards you have. I'd probably look for pairs first and only if there are no pairs do you look for straights or flushes and I'd make a function to look for each.

相关问答

更多
  • expand.grid函数应该是有帮助的: # Define suits, cards, values suits <- c("Diamonds", "Clubs", "Hearts", "Spades") cards <- c("Ace", "Deuce", "Three", "Four","Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King") values <- c(0, 2:9, rep(10, 4)) tota ...
  • 摆脱Card card1; 这种方法中的变量。 它不仅不需要,它是危险的,并且冒着抛出NullPointerException的风险。 而是使用当前实例中从此方法调用此方法的字段。 要确定排名,您需要使用for循环遍历数组,然后确定当前卡的字段相对于参数Card的字段的位置,然后返回相应的数字。 Get rid of the Card card1; variable in this method. Not only is it not needed, it's dangerous and risks you ...
  • @DamirDžilić - 没有任何真实的代码可以发表评论,我们只能给出概念建议。 你将不得不将每一手牌与所有可能的扑克手牌进行比较,从最高等级的手牌到一对牌手。 我个人建议每张卡都是一个对象: var card = {suit: "S", value: 9}; 然后,一只手将是一组卡片对象。 然后,您可以分别查看套装和卡片价值。 如果卡值在2到14之间并且您转换为J,Q,K,A仅用于显示,则会更容易。 然后,每个可能的扑克手(一对,三种,四种,同花顺,直线等等)将按照他们在扑克中的价值得分(对= 1, ...
  • 您的变量i达到104,但在每个循环中,您dealCard在两个dealCard牌上都叫做dealCard 。 这是null值来自哪里。 你只需要循环到52: for (int i = 1; i <=52; i++) { 你使用printf输出是错误的,这个函数只需要一个格式化程序。 您的版本只输出myDeck.dealCard()的值,并且还调用(但不使用) yourDeck.dealCard() 。 要创建一个包含两个调用输出的行,请使用如下所示的内容: System.out.printf("%-20 ...
  • 您可以使用Rank-Suite表格将卡片表示为条款。 为了检查卡片是否来自同一个套件定义了一个谓词: same_suit(_-S, _-S). 你可以使用这个谓词来检查你是否有一个flush: ?- Cards = [1-d, 2-d, 3-d, 4-d, 5-d], maplist(same_suit(_-S), Cards). Cards = [1-d, 2-d, 3-d, 4-d, 5-d], S = d. 为了检测你是否有一对,两对,三类,满堂,或四类,你可以计算手中的对数,然后将结果映射到手的 ...
  • 要循环上面显示的内容,可以使用一行,因为每个div列为3,如果达到12(3x4),它将转到新行。 像这样的东西:
    @foreach (var row in CK.Cards("ID='" + TknParams.ID + "'")) {